home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Presentations / Presentations ’92 / Optimizing Source Code / Shane Looker < prev    next >
MacBinary  |  1992-05-14  |  41.0 KB  |  [MW2D/MWII]

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: MacBinary (archive/macBinary).

You can browse this item here: Shane Looker

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert MacWrite Document (document/macWrite) idMeta Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
100% file MacBinary II, inited, Sat May 9 14:58:23 1992, modified Thu May 14 15:31:42 1992, creator 'MWII', type 'MW2D', 41472 bytes "Shane Looker" , at 0xa280 286 bytes resource default (weak)
99% file data default
74% TrID Mac MacWrite II document (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[MW2D]
macFileCreator[MWII]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0c 53 68 61 6e 65 20 | 4c 6f 6f 6b 65 72 00 00 |..Shane |Looker..|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 4d 57 32 44 4d 57 49 | 49 01 00 00 00 00 00 00 |.MW2DMWI|I.......|
|00000050| 00 00 00 00 00 a2 00 00 | 00 01 1e a6 31 d1 4f a6 |........|....1.O.|
|00000060| 38 70 9e 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |8p......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 4d 94 00 00 |........|....M...|
|00000080| 00 2e 00 2e 00 03 00 00 | 00 48 00 48 00 00 00 00 |........|.H.H....|
|00000090| 02 da 02 28 ff e1 ff e2 | 02 f9 02 46 03 47 05 28 |...(....|...F.G.(|
|000000a0| 03 fc 00 02 00 00 00 48 | 00 48 00 00 00 00 02 da |.......H|.H......|
|000000b0| 02 28 00 01 00 00 00 64 | 00 00 00 01 00 01 01 01 |.(.....d|........|
|000000c0| 00 00 00 01 27 0f 00 01 | 00 01 00 00 00 00 00 00 |....'...|........|
|000000d0| 00 00 00 00 00 00 00 02 | 00 19 01 90 00 00 00 00 |........|........|
|000000e0| 00 40 00 00 00 00 00 00 | 00 00 00 01 00 00 00 00 |.@......|........|
|000000f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 06 80 |........|........|
|00000100| 01 00 00 00 01 00 01 06 | 12 01 00 02 01 2c 00 00 |........|.....,..|
|00000110| 00 00 00 3c 00 0a 03 1a | 80 00 02 66 80 00 00 48 |...<....|...f...H|
|00000120| 80 00 00 48 80 00 00 48 | 80 00 00 24 80 00 00 02 |...H...H|...$....|
|00000130| 00 36 00 00 20 00 00 00 | fd 80 33 33 00 06 00 00 |.6.. ...|..33....|
|00000140| 00 00 00 01 a0 00 00 01 | 00 00 00 01 6f 66 00 00 |........|....of..|
|00000150| 00 00 00 00 00 08 00 09 | 00 01 00 00 00 00 00 00 |........|........|
|00000160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000170| 00 00 00 00 00 00 73 62 | 00 00 73 62 00 00 00 00 |......sb|..sb....|
|00000180| 00 28 00 04 01 8b 02 7b | 00 48 00 48 00 00 00 00 |.(.....{|.H.H....|
|00000190| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000001f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000200| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000210| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000220| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000230| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000240| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000250| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000260| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000270| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000280| 00 00 00 6b 00 05 00 03 | 06 47 65 6e 65 76 61 00 |...k....|.Geneva.|
|00000290| 00 10 08 50 61 6c 61 74 | 69 6e 6f 0e 50 61 6c 61 |...Palat|ino.Pala|
|000002a0| 74 69 6e 6f 2d 52 6f 6d | 61 6e 00 15 09 48 65 6c |tino-Rom|an...Hel|
|000002b0| 76 65 74 69 63 61 09 48 | 65 6c 76 65 74 69 63 61 |vetica.H|elvetica|
|000002c0| 00 0d 0d 5a 61 70 66 20 | 44 69 6e 67 62 61 74 73 |...Zapf |Dingbats|
|000002d0| 0c 5a 61 70 66 44 69 6e | 67 62 61 74 73 00 16 07 |.ZapfDin|gbats...|
|000002e0| 43 6f 75 72 69 65 72 07 | 43 6f 75 72 69 65 72 00 |Courier.|Courier.|
|000002f0| 00 00 00 00 01 0b 50 61 | 6c 61 74 69 6e 6f 20 31 |......Pa|latino 1|
|00000300| 34 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |4.......|........|
|00000310| 00 00 00 00 00 00 00 00 | 10 00 38 00 01 01 00 00 |........|..8.....|
|00000320| 00 00 96 00 02 00 03 00 | 30 00 00 01 64 00 02 00 |........|0...d...|
|00000330| 10 00 24 00 20 01 64 00 | 02 00 15 00 28 00 00 01 |..$. .d.|....(...|
|00000340| 64 00 44 00 10 00 28 00 | 00 01 64 00 01 00 15 00 |d.D...(.|..d.....|
|00000350| 24 00 20 01 64 00 1a 00 | 0d 00 28 00 00 01 64 00 |$. .d...|..(...d.|
|00000360| 02 00 10 00 20 00 20 01 | 64 00 07 00 10 00 28 00 |.... . .|d.....(.|
|00000370| 02 01 64 00 0c 00 10 00 | 28 00 01 01 64 00 00 06 |..d.....|(...d...|
|00000380| 03 20 4d 61 6e 64 61 74 | 6f 72 79 20 62 75 7a 7a |. Mandat|ory buzz|
|00000390| 77 6f 72 64 20 61 73 20 | 72 65 71 75 69 72 65 64 |word as |required|
|000003a0| 20 66 6f 72 20 61 6c 6c | 20 64 6f 63 75 6d 65 6e | for all| documen|
|000003b0| 74 73 20 70 75 72 70 6f | 72 74 69 6e 67 20 74 6f |ts purpo|rting to|
|000003c0| 20 68 61 76 65 20 61 20 | 75 73 65 66 75 6c 20 61 | have a |useful a|
|000003d0| 6e 64 2f 6f 72 20 73 63 | 68 6f 6c 61 72 6c 79 20 |nd/or sc|holarly |
|000003e0| 62 65 6e 74 2e 00 00 00 | 00 00 00 00 00 00 00 00 |bent....|........|
|000003f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000400| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000410| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000420| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000430| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000440| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000450| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000460| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000470| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000480| 00 00 00 65 00 00 00 04 | 00 04 00 65 00 00 00 12 |...e....|...e....|
|00000490| 00 01 00 00 00 01 00 02 | 00 00 00 01 00 03 00 00 |........|........|
|000004a0| 00 63 00 00 00 06 00 01 | 00 00 00 65 00 00 00 08 |.c......|...e....|
|000004b0| 03 00 00 00 00 00 00 00 | 61 72 09 2a 63 63 6f 6e |........|ar.*ccon|
|000004c0| 63 61 74 28 63 68 61 72 | 20 2a 73 2c 20 63 68 61 |cat(char| *s, cha|
|000004d0| 72 20 2a 74 29 3b 0d 76 | 6f 69 64 09 50 43 6f 6e |r *t);.v|oid.PCon|
|000004e0| 63 61 74 28 63 68 61 72 | 20 2a 73 2c 20 63 68 61 |cat(char| *s, cha|
|000004f0| 72 20 2a 74 29 3b 0d 0d | 23 64 65 66 69 6e 65 09 |r *t);..|#define.|
|00000500| 6b 4c 69 6d 69 74 09 31 | 30 30 30 0d 69 6e 74 20 |kLimit.1|000.int |
|00000510| 6d 61 69 6e 28 29 0d 7b | 0d 09 53 74 72 32 35 35 |main().{|..Str255|
|00000520| 09 74 65 73 74 31 2c 20 | 74 65 73 74 32 2c 20 74 |.test1, |test2, t|
|00000530| 65 73 74 33 2c 20 74 65 | 73 74 34 3b 0d 09 6c 6f |est3, te|st4;..lo|
|00000540| 6e 67 09 73 74 61 72 74 | 54 69 63 6b 42 6c 6f 63 |ng.start|TickBloc|
|00000550| 6b 2c 20 65 6e 64 54 69 | 63 6b 42 6c 6f 63 6b 2c |k, endTi|ckBlock,|
|00000560| 20 73 74 61 72 74 54 69 | 63 6b 51 75 69 63 6b 2c | startTi|ckQuick,|
|00000570| 20 65 6e 64 54 69 63 6b | 51 75 69 63 6b 3b 00 00 | endTick|Quick;..|
|00000580| 02 00 16 00 28 00 00 01 | 64 00 10 00 10 00 38 00 |....(...|d.....8.|
|00000590| 01 01 64 00 01 00 10 00 | 48 00 01 01 64 00 01 00 |..d.....|H...d...|
|000005a0| 10 00 30 00 01 01 64 00 | 01 00 10 00 30 00 00 01 |..0...d.|....0...|
|000005b0| 64 00 01 00 10 00 30 00 | 02 01 64 00 00 07 e4 00 |d.....0.|..d.....|
|000005c0| 02 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000005d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 ff ff ff |........|........|
|000005e0| ff 00 00 00 00 00 00 00 | 00 00 20 ff ff ff ff 2e |........|.. .....|
|000005f0| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000600| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000610| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000620| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000630| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000640| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000650| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000660| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff 2e |.. .....|.. .....|
|00000670| 00 00 20 ff ff ff ff 2e | 00 00 20 ff ff ff ff f9 |.. .....|.. .....|
|00000680| 00 02 ff 2e 00 00 20 ff | ff ff ff 2e 00 00 02 00 |...... .|........|
|00000690| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000006a0| 00 00 00 00 00 00 00 00 | 00 00 00 ff ff ff ff 00 |........|........|
|000006b0| 00 00 00 00 00 00 00 00 | 90 ff ff ff ff 03 a4 00 |........|........|
|000006c0| 90 c0 02 00 00 03 ae 00 | 36 d2 04 00 00 47 60 00 |........|6....G`.|
|000006d0| 00 86 50 00 02 20 14 00 | 02 2a 94 43 4f 44 45 07 |..P.. ..|.*.CODE.|
|000006e0| 07 00 0a 07 07 00 28 07 | 07 03 ae 00 00 00 0e 00 |......(.|........|
|000006f0| 00 61 b2 ff d3 1a c0 00 | 29 06 10 00 36 f3 a4 00 |.a......|)...6...|
|00000700| 36 d2 36 00 02 29 72 00 | 02 29 82 00 90 4e 2a 00 |6.6..)r.|.)...N*.|
|00000710| 36 d2 04 00 2b 6a 10 00 | 2c 49 b0 00 05 d5 94 00 |6...+j..|,I......|
|00000720| 00 02 c2 44 45 20 00 00 | 91 47 f6 00 00 37 e6 00 |...DE ..|.G...7..|
|00000730| 90 88 98 00 90 4e 2a 00 | 2b 6a 10 00 08 79 0c 00 |.....N*.|+j...y..|
|00000740| 00 00 e0 00 00 37 e6 00 | 2c e8 1e 00 29 04 dc 00 |.....7..|,...)...|
|00000750| 91 43 bc 00 00 00 36 00 | 19 00 00 00 00 00 1a 80 |.C....6.|........|
|00000760| 00 ff ee 00 01 00 09 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000770| 00 00 00 80 00 ff ff ff | ff 00 00 00 00 ff ff ff |........|........|
|00000780| ff 00 90 ff ff ff ff 03 | a4 00 90 c0 02 00 00 03 |........|........|
|00000790| ae 00 36 d2 04 00 00 47 | 60 00 00 86 50 00 02 20 |..6....G|`...P.. |
|000007a0| 14 00 02 2a 94 43 4f 44 | 45 07 07 00 0a 07 07 00 |...*.COD|E.......|
|000007b0| 28 07 07 03 ae 00 00 00 | 0e 00 00 61 b2 ff d3 1a |(.......|...a....|
|000007c0| c0 00 29 06 10 00 36 f3 | a4 00 36 d2 36 00 02 29 |..)...6.|..6.6..)|
|000007d0| 72 00 02 29 82 00 90 4e | 2a 00 36 d2 04 00 2b 6a |r..)...N|*.6...+j|
|000007e0| 10 00 2c 49 b0 00 05 d5 | 94 00 00 02 c2 44 45 20 |..,I....|.....DE |
|000007f0| 00 00 91 47 f6 00 00 37 | e6 00 90 88 98 00 90 4e |...G...7|.......N|
|00000800| 2a 00 2b 6a 10 00 08 79 | 0c 00 00 00 e0 00 00 37 |*.+j...y|.......7|
|00000810| e6 00 2c e8 1e 00 29 04 | dc 00 91 43 bc 00 00 00 |..,...).|...C....|
|00000820| 36 00 53 00 00 00 00 00 | 00 00 00 00 12 00 00 00 |6.S.....|........|
|00000830| 00 00 00 00 00 00 00 00 | 00 00 00 00 01 00 00 ff |........|........|
|00000840| ff ff ff 00 00 00 00 ff | ff ff ff 00 90 ff ff ff |........|........|
|00000850| ff 03 a4 00 90 c0 02 00 | 00 03 ae 00 36 d2 04 00 |........|....6...|
|00000860| 00 47 60 00 00 86 50 00 | 02 20 14 00 02 2a 94 43 |.G`...P.|. ...*.C|
|00000870| 4f 44 45 07 07 00 0a 07 | 07 00 28 07 07 03 00 0b |ODE.....|..(.....|
|00000880| 68 61 6e 20 6f 6c 64 65 | 72 20 63 6f 64 69 6e 67 |han olde|r coding|
|00000890| 20 73 74 79 6c 65 73 2e | 20 28 4f 66 20 63 6f 75 | styles.| (Of cou|
|000008a0| 72 73 65 20 69 74 20 68 | 61 73 20 61 6c 77 61 79 |rse it h|as alway|
|000008b0| 73 20 62 65 65 6e 20 70 | 6f 73 73 69 62 6c 65 20 |s been p|ossible |
|000008c0| 74 6f 20 6a 75 73 74 20 | 77 72 69 74 65 20 62 61 |to just |write ba|
|000008d0| 64 20 63 6f 64 65 2c 20 | 72 65 67 61 72 64 6c 65 |d code, |regardle|
|000008e0| 73 73 20 6f 66 20 74 68 | 65 20 70 72 6f 67 72 61 |ss of th|e progra|
|000008f0| 6d 6d 69 6e 67 20 6c 61 | 6e 67 75 61 67 65 20 75 |mming la|nguage u|
|00000900| 73 65 64 2e 29 20 54 68 | 65 72 65 20 69 73 20 61 |sed.) Th|ere is a|
|00000910| 6c 73 6f 20 61 20 64 69 | 73 74 69 6e 63 74 20 74 |lso a di|stinct t|
|00000920| 65 6e 64 65 6e 63 79 20 | 66 6f 72 20 64 65 76 65 |endency |for deve|
|00000930| 6c 6f 70 65 72 73 20 74 | 6f 20 77 72 69 74 65 20 |lopers t|o write |
|00000940| 63 6f 64 65 20 77 68 69 | 63 68 20 70 65 72 66 6f |code whi|ch perfo|
|00000950| 72 6d 73 20 61 63 63 65 | 70 74 61 62 6c 79 20 6f |rms acce|ptably o|
|00000960| 6e 20 68 69 67 68 65 72 | 20 65 6e 64 20 73 79 73 |n higher| end sys|
|00000970| 74 65 6d 73 2c 20 62 75 | 74 20 68 61 73 20 73 6c |tems, bu|t has sl|
|00000980| 75 67 67 69 73 68 20 70 | 65 72 66 6f 72 6d 61 6e |uggish p|erforman|
|00000990| 63 65 20 6f 6e 20 6c 6f | 77 20 65 6e 64 20 6d 61 |ce on lo|w end ma|
|000009a0| 63 68 69 6e 65 73 2e 20 | 54 68 69 73 20 63 61 6e |chines. |This can|
|000009b0| 20 62 65 20 73 65 65 6e | 20 69 6e 20 73 6f 6d 65 | be seen| in some|
|000009c0| 20 73 6f 66 74 77 61 72 | 65 20 77 68 65 72 65 20 | softwar|e where |
|000009d0| 69 74 20 74 61 6b 65 73 | 20 61 20 6e 6f 74 69 63 |it takes| a notic|
|000009e0| 65 61 62 6c 65 20 6c 65 | 6e 67 74 68 20 6f 66 20 |eable le|ngth of |
|000009f0| 74 69 6d 65 20 66 6f 72 | 20 61 20 6d 65 6e 75 20 |time for| a menu |
|00000a00| 74 6f 20 64 72 6f 70 20 | 6f 72 20 70 6f 70 2d 75 |to drop |or pop-u|
|00000a10| 70 2c 20 6f 72 20 66 6f | 72 20 73 63 72 6f 6c 6c |p, or fo|r scroll|
|00000a20| 69 6e 67 20 74 6f 20 73 | 74 61 72 74 20 6f 6e 63 |ing to s|tart onc|
|00000a30| 65 20 74 68 65 20 6d 6f | 75 73 65 20 62 75 74 74 |e the mo|use butt|
|00000a40| 6f 6e 20 68 61 73 20 62 | 65 65 6e 20 68 65 6c 64 |on has b|een held|
|00000a50| 20 64 6f 77 6e 2e 0d 41 | 6c 6f 6e 67 20 73 69 64 | down..A|long sid|
|00000a60| 65 20 74 68 65 73 65 20 | 6e 65 77 20 70 61 72 61 |e these |new para|
|00000a70| 64 69 67 6d 73 2c 20 6e | 65 77 65 72 2c 20 6d 6f |digms, n|ewer, mo|
|00000a80| ae 00 00 00 0e 00 00 61 | b2 ff d3 1a c0 00 29 06 |.......a|......).|
|00000a90| 10 00 36 f3 a4 00 36 d2 | 36 00 02 29 72 00 02 29 |..6...6.|6..)r..)|
|00000aa0| 82 00 90 4e 2a 00 36 d2 | 04 00 2b 6a 10 00 2c 49 |...N*.6.|..+j..,I|
|00000ab0| b0 00 05 d5 94 00 00 02 | c2 44 45 20 00 00 91 47 |........|.DE ...G|
|00000ac0| f6 00 00 37 e6 00 90 88 | 98 00 90 4e 2a 00 2b 6a |...7....|...N*.+j|
|00000ad0| 10 00 08 79 0c 00 00 00 | e0 00 00 37 e6 00 2c e8 |...y....|...7..,.|
|00000ae0| 1e 00 29 04 dc 00 91 43 | bc 00 00 00 36 00 0d 00 |..)....C|....6...|
|00000af0| 00 00 00 00 00 00 00 00 | 12 00 00 00 00 00 00 00 |........|........|
|00000b00| 00 00 00 00 00 80 00 00 | 01 00 00 ff ff ff ff ff |........|........|
|00000b10| ff ff ff ff ff ff ff 00 | 90 ff ff ff ff 03 a4 00 |........|........|
|00000b20| 90 c0 02 00 00 03 ae 00 | 36 d2 04 00 00 47 60 00 |........|6....G`.|
|00000b30| 00 86 50 00 02 20 14 00 | 02 2a 94 43 4f 44 45 07 |..P.. ..|.*.CODE.|
|00000b40| 07 00 0a 07 07 00 28 07 | 07 03 ae 00 00 00 0e 00 |......(.|........|
|00000b50| 00 61 b2 ff d3 1a c0 00 | 29 06 10 00 36 f3 a4 00 |.a......|)...6...|
|00000b60| 36 d2 36 00 02 29 72 00 | 02 29 82 00 90 4e 2a 00 |6.6..)r.|.)...N*.|
|00000b70| 36 d2 04 00 2b 6a 10 00 | 2c 49 b0 00 05 d5 ff f2 |6...+j..|,I......|
|00000b80| 61 6e 64 2f 6f 72 20 66 | 61 73 74 65 72 20 73 69 |and/or f|aster si|
|00000b90| 6e 63 65 20 69 74 20 63 | 61 6e 20 6f 70 74 69 6d |nce it c|an optim|
|00000ba0| 69 7a 65 2e 20 49 6e 20 | 72 65 61 6c 69 74 79 2c |ize. In |reality,|
|00000bb0| 20 6e 6f 20 63 6f 6d 70 | 69 6c 65 72 20 63 61 6e | no comp|iler can|
|00000bc0| 20 66 69 6e 65 20 74 75 | 6e 65 20 6f 62 6a 65 63 | fine tu|ne objec|
|00000bd0| 74 20 63 6f 64 65 20 74 | 6f 20 74 68 65 20 73 61 |t code t|o the sa|
|00000be0| 6d 65 20 65 66 66 69 63 | 69 65 6e 63 79 20 61 73 |me effic|iency as|
|00000bf0| 20 61 20 63 6f 6d 70 65 | 74 65 6e 74 20 68 75 6d | a compe|tent hum|
|00000c00| 61 6e 20 77 6f 72 6b 69 | 6e 67 20 69 6e 20 61 73 |an worki|ng in as|
|00000c10| 73 65 6d 62 6c 79 20 6c | 61 6e 67 75 61 67 65 2e |sembly l|anguage.|
|00000c20| 20 53 69 6e 63 65 20 69 | 74 20 69 73 20 69 6d 70 | Since i|t is imp|
|00000c30| 72 61 63 74 69 63 61 6c | 20 74 6f 20 63 6f 64 65 |ractical| to code|
|00000c40| 20 6c 61 72 67 65 20 61 | 70 70 6c 69 63 61 74 69 | large a|pplicati|
|00000c50| 6f 6e 73 20 69 6e 20 61 | 73 73 65 6d 62 6c 79 20 |ons in a|ssembly |
|00000c60| 6c 61 6e 67 75 61 67 65 | 2c 20 6d 6f 73 74 20 70 |language|, most p|
|00000c70| 72 6f 67 72 61 6d 6d 65 | 72 73 20 61 63 63 65 70 |rogramme|rs accep|
|00000c80| 74 20 74 68 65 20 70 65 | 72 66 6f 72 6d 61 6e 63 |t the pe|rformanc|
|00000c90| 65 20 68 69 74 20 74 68 | 65 79 20 74 61 6b 65 20 |e hit th|ey take |
|00000ca0| 61 6e 64 20 68 6f 70 65 | 20 6e 6f 62 6f 64 79 20 |and hope| nobody |
|00000cb0| 77 69 6c 6c 20 6e 6f 74 | 69 63 65 2e 0d 54 68 65 |will not|ice..The|
|00000cc0| 72 65 20 69 73 20 61 20 | 6d 69 64 64 6c 65 20 67 |re is a |middle g|
|00000cd0| 72 6f 75 6e 64 20 62 65 | 74 77 65 65 6e 20 68 6f |round be|tween ho|
|00000ce0| 70 69 6e 67 20 74 68 65 | 20 63 6f 6d 70 69 6c 65 |ping the| compile|
|00000cf0| 72 20 63 61 6e 20 6d 61 | 6b 65 20 74 68 65 20 63 |r can ma|ke the c|
|00000d00| 6f 64 65 20 62 65 74 74 | 65 72 20 61 6e 64 20 77 |ode bett|er and w|
|00000d10| 72 69 74 69 6e 67 20 69 | 6e 20 61 73 73 65 6d 62 |riting i|n assemb|
|00000d20| 6c 79 20 6c 61 6e 67 75 | 61 67 65 2e 20 54 68 61 |ly langu|age. Tha|
|00000d30| 74 20 61 6c 74 65 72 6e | 61 74 69 76 65 20 69 73 |t altern|ative is|
|00000d40| 20 73 6f 75 72 63 65 20 | 63 6f 64 65 20 6f 70 74 | source |code opt|
|00000d50| 69 6d 69 7a 61 74 69 6f | 6e 2e 20 49 74 20 64 6f |imizatio|n. It do|
|00000d60| 65 73 20 72 65 71 75 69 | 72 65 73 20 73 6f 6d 65 |es requi|res some|
|00000d70| 20 6b 6e 6f 77 6c 65 64 | 67 65 20 6f 66 20 61 73 | knowled|ge of as|
|00000d80| 00 02 94 00 00 02 c2 44 | 45 20 00 00 91 47 f6 00 |.......D|E ...G..|
|00000d90| 00 37 e6 00 90 88 98 00 | 90 4e 2a 00 2b 6a 10 00 |.7......|.N*.+j..|
|00000da0| 08 79 0c 00 00 00 e0 00 | 00 37 e6 00 2c e8 1e 00 |.y......|.7..,...|
|00000db0| 29 04 dc 00 91 43 bc 00 | 00 00 36 00 09 00 00 00 |)....C..|..6.....|
|00000dc0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000dd0| 00 00 00 00 00 00 01 00 | 00 ff ff ff ff 00 00 00 |........|........|
|00000de0| 00 ff ff ff ff 00 90 ff | ff ff ff 03 a4 00 90 c0 |........|........|
|00000df0| 02 00 00 03 ae 00 36 d2 | 04 00 00 47 60 00 00 86 |......6.|...G`...|
|00000e00| 50 00 02 20 14 00 02 2a | 94 43 4f 44 45 07 07 00 |P.. ...*|.CODE...|
|00000e10| 0a 07 07 00 28 07 07 03 | ae 00 00 00 0e 00 00 61 |....(...|.......a|
|00000e20| b2 ff d3 1a c0 00 29 06 | 10 00 36 f3 a4 00 36 d2 |......).|..6...6.|
|00000e30| 36 00 02 29 72 00 02 29 | 82 00 90 4e 2a 00 36 d2 |6..)r..)|...N*.6.|
|00000e40| 04 00 2b 6a 10 00 2c 49 | b0 00 05 d5 94 00 00 02 |..+j..,I|........|
|00000e50| c2 44 45 20 00 00 91 47 | f6 00 00 37 e6 00 90 88 |.DE ...G|...7....|
|00000e60| 98 00 90 4e 2a 00 2b 6a | 10 00 08 79 0c 00 00 00 |...N*.+j|...y....|
|00000e70| e0 00 00 37 e6 00 2c e8 | 1e 00 29 04 dc 00 91 43 |...7..,.|..)....C|
|00000e80| bc 00 00 00 36 00 01 00 | 02 00 00 00 00 00 00 00 |....6...|........|
|00000e90| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000ea0| 00 00 00 ff ff ff ff 00 | 00 00 00 00 00 00 00 02 |........|........|
|00000eb0| 20 01 8c 00 00 2e 2b 02 | 20 ff ff ff ff 2e 2b 00 | .....+.| .....+.|
|00000ec0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000ed0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000ee0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000ef0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f00| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f10| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f20| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f30| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f40| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00000f50| 02 00 01 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000f60| 00 00 00 00 00 00 00 00 | 00 00 01 00 00 ff ff ff |........|........|
|00000f70| ff 00 00 00 00 ff ff ff | ff 00 90 ff ff ff ff ef |........|........|
|00000f80| 6f 20 77 61 79 73 20 74 | 6f 20 64 65 74 65 72 6d |o ways t|o determ|
|00000f90| 69 6e 65 20 77 68 65 72 | 65 20 6f 70 74 69 6d 69 |ine wher|e optimi|
|00000fa0| 7a 61 74 69 6f 6e 20 6e | 65 65 64 73 20 74 6f 20 |zation n|eeds to |
|00000fb0| 62 65 20 64 6f 6e 65 3b | 20 62 79 20 70 72 6f 66 |be done;| by prof|
|00000fc0| 69 6c 69 6e 67 20 74 68 | 65 20 65 78 65 63 75 74 |iling th|e execut|
|00000fd0| 69 6e 67 20 63 6f 64 65 | 20 61 6e 64 20 62 79 20 |ing code| and by |
|00000fe0| 61 63 74 75 61 6c 6c 79 | 20 75 73 69 6e 67 20 74 |actually| using t|
|00000ff0| 68 65 20 63 6f 64 65 2e | 20 55 6e 74 69 6c 20 79 |he code.| Until y|
|00001000| 6f 75 20 6b 6e 6f 77 6e | 20 77 68 65 72 65 20 63 |ou known| where c|
|00001010| 6f 64 65 20 69 73 20 61 | 63 74 75 61 6c 6c 79 20 |ode is a|ctually |
|00001020| 73 6c 6f 77 2c 20 74 68 | 65 72 65 20 69 73 20 6e |slow, th|ere is n|
|00001030| 6f 20 77 61 79 20 74 6f | 20 69 6d 70 72 6f 76 65 |o way to| improve|
|00001040| 20 70 65 72 66 6f 72 6d | 61 6e 63 65 2e 20 59 6f | perform|ance. Yo|
|00001050| 75 20 6d 61 79 20 6f 70 | 74 69 6d 69 7a 65 20 61 |u may op|timize a|
|00001060| 20 73 69 6e 67 6c 65 20 | 72 6f 75 74 69 6e 65 20 | single |routine |
|00001070| 77 68 69 63 68 20 79 6f | 75 20 62 65 6c 69 65 76 |which yo|u believ|
|00001080| 00 02 ff 03 a4 00 90 c0 | 02 00 00 03 ae 00 36 d2 |........|......6.|
|00001090| 04 00 00 47 60 00 00 86 | 50 00 02 20 14 00 02 2a |...G`...|P.. ...*|
|000010a0| 94 43 4f 44 45 07 07 00 | 0a 07 07 00 28 07 07 03 |.CODE...|....(...|
|000010b0| ae 00 00 00 0e 00 00 61 | b2 ff d3 1a c0 00 29 06 |.......a|......).|
|000010c0| 10 00 36 f3 a4 00 36 d2 | 36 00 02 29 72 00 02 29 |..6...6.|6..)r..)|
|000010d0| 82 00 90 4e 2a 00 36 d2 | 04 00 2b 6a 10 00 2c 49 |...N*.6.|..+j..,I|
|000010e0| b0 00 05 d5 94 00 00 02 | c2 44 45 20 00 00 91 47 |........|.DE ...G|
|000010f0| f6 00 00 37 e6 00 90 88 | 98 00 90 4e 2a 00 2b 6a |...7....|...N*.+j|
|00001100| 10 00 08 79 0c 00 00 00 | e0 00 00 37 e6 00 2c e8 |...y....|...7..,.|
|00001110| 1e 00 29 04 dc 00 91 43 | bc 00 00 00 36 00 01 00 |..)....C|....6...|
|00001120| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001130| 00 00 00 00 00 00 00 00 | 00 00 00 ff ff ff ff 00 |........|........|
|00001140| 00 00 00 00 00 00 00 00 | 20 00 6c 00 00 2e 44 02 |........| .l...D.|
|00001150| 20 ff ff ff ff 2e 2b 00 | 20 ff ff ff ff 2e 00 00 | .....+.| .......|
|00001160| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00001170| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00001180| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|00001190| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|000011a0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|000011b0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|000011c0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|000011d0| 20 ff ff ff ff 2e 00 00 | 20 ff ff ff ff 2e 00 00 | .......| .......|
|000011e0| 20 ff ff ff ff 2e 00 00 | 01 00 03 00 00 00 00 00 | .......|........|
|000011f0| 00 00 12 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001200| 00 00 01 00 00 ff ff ff | ff 00 00 00 00 ff ff ff |........|........|
|00001210| ff 00 90 ff ff ff ff 03 | a4 00 90 c0 02 00 00 03 |........|........|
|00001220| ae 00 36 d2 04 00 00 47 | 60 00 00 86 50 00 02 20 |..6....G|`...P.. |
|00001230| 14 00 02 2a 94 43 4f 44 | 45 07 07 00 0a 07 07 00 |...*.COD|E.......|
|00001240| 28 07 07 03 ae 00 00 00 | 0e 00 00 61 b2 ff d3 1a |(.......|...a....|
|00001250| c0 00 29 06 10 00 36 f3 | a4 00 36 d2 36 00 02 29 |..)...6.|..6.6..)|
|00001260| 72 00 02 29 82 00 90 4e | 2a 00 36 d2 04 00 2b 6a |r..)...N|*.6...+j|
|00001270| 10 00 2c 49 b0 00 05 d5 | 94 00 00 02 c2 44 00 16 |..,I....|.....D..|
|00001280| 20 6f 77 6e 20 70 72 6f | 66 69 6c 69 6e 67 20 6c | own pro|filing l|
|00001290| 69 62 72 61 72 69 65 73 | 2e 20 54 68 65 20 70 72 |ibraries|. The pr|
|000012a0| 6f 66 69 6c 65 72 20 77 | 69 6c 6c 20 63 6f 6c 6c |ofiler w|ill coll|
|000012b0| 65 63 74 20 73 74 61 74 | 69 73 74 69 63 73 20 61 |ect stat|istics a|
|000012c0| 62 6f 75 74 20 77 68 69 | 63 68 20 72 6f 75 74 69 |bout whi|ch routi|
|000012d0| 6e 65 73 20 61 72 65 20 | 63 61 6c 6c 65 64 2c 20 |nes are |called, |
|000012e0| 68 6f 77 20 6f 66 74 65 | 6e 20 74 68 65 79 20 61 |how ofte|n they a|
|000012f0| 72 65 20 63 61 6c 6c 65 | 64 20 64 75 72 69 6e 67 |re calle|d during|
|00001300| 20 74 68 65 20 70 72 6f | 67 72 61 6d 2c 20 61 6e | the pro|gram, an|
|00001310| 64 20 77 68 61 74 20 70 | 65 72 63 65 6e 74 61 67 |d what p|ercentag|
|00001320| 65 20 6f 66 20 74 68 65 | 20 70 72 6f 67 72 61 6d |e of the| program|
|00001330| d5 73 20 65 78 65 63 75 | 74 69 6f 6e 20 74 69 6d |.s execu|tion tim|
|00001340| 65 20 69 73 20 73 70 65 | 6e 74 20 69 6e 20 65 61 |e is spe|nt in ea|
|00001350| 63 68 20 72 6f 75 74 69 | 6e 65 2e 20 45 78 61 6d |ch routi|ne. Exam|
|00001360| 69 6e 65 20 68 69 67 68 | 20 70 65 72 63 65 6e 74 |ine high| percent|
|00001370| 61 67 65 20 72 6f 75 74 | 69 6e 65 73 20 61 6e 64 |age rout|ines and|
|00001380| 20 74 69 67 68 74 65 6e | 20 74 68 65 6d 20 75 70 | tighten| them up|
|00001390| 20 61 73 20 6d 75 63 68 | 20 61 73 20 70 6f 73 73 | as much| as poss|
|000013a0| 69 62 6c 65 2e 0d 50 72 | 6f 66 69 6c 65 72 73 20 |ible..Pr|ofilers |
|000013b0| 63 61 6e 20 62 65 20 75 | 73 65 66 75 6c 2c 20 62 |can be u|seful, b|
|000013c0| 75 74 20 74 68 65 79 20 | 68 61 76 65 20 74 68 72 |ut they |have thr|
|000013d0| 65 65 20 6d 61 69 6e 20 | 64 72 61 77 62 61 63 6b |ee main |drawback|
|000013e0| 73 2e 20 54 68 65 20 66 | 69 72 73 74 20 69 73 20 |s. The f|irst is |
|000013f0| 74 68 61 74 20 74 68 65 | 79 20 6e 6f 72 6d 61 6c |that the|y normal|
|00001400| 6c 79 20 72 65 71 75 69 | 72 65 20 73 6f 75 72 63 |ly requi|re sourc|
|00001410| 65 20 63 6f 64 65 20 63 | 68 61 6e 67 65 73 20 74 |e code c|hanges t|
|00001420| 6f 20 62 65 20 69 6e 76 | 6f 6b 65 64 20 61 6e 64 |o be inv|oked and|
|00001430| 20 75 73 65 64 2e 20 53 | 65 63 6f 6e 64 6c 79 2c | used. S|econdly,|
|00001440| 20 74 68 65 79 20 64 6f | 20 6e 6f 74 20 73 68 6f | they do| not sho|
|00001450| 77 20 74 6f 20 77 68 61 | 74 20 65 78 74 65 6e 74 |w to wha|t extent|
|00001460| 20 61 20 66 75 6e 63 74 | 69 6f 6e 20 69 73 20 61 | a funct|ion is a|
|00001470| 63 74 75 61 6c 6c 79 20 | 75 73 65 64 2e 20 4f 6e |ctually |used. On|
|00001480| 65 20 72 6f 75 74 69 6e | 65 20 6d 61 79 20 6f 6e |e routin|e may on|
|00001490| 6c 79 20 68 61 76 65 20 | 61 20 72 75 6e 20 70 65 |ly have |a run pe|
|000014a0| 72 63 65 6e 74 61 67 65 | 20 6f 66 20 2e 35 25 20 |rcentage| of .5% |
|000014b0| 66 6f 72 20 69 6e 73 74 | 61 6e 63 65 2c 20 62 75 |for inst|ance, bu|
|000014c0| 74 20 69 74 20 6d 61 79 | 20 69 6e 76 6f 6b 65 20 |t it may| invoke |
|000014d0| 33 30 20 6f 74 68 65 72 | 20 72 6f 75 74 69 6e 65 |30 other| routine|
|000014e0| 73 20 77 68 69 63 68 20 | 68 61 76 65 20 61 20 63 |s which |have a c|
|000014f0| 75 6d 75 6c 61 74 69 76 | 65 20 74 6f 74 61 6c 20 |umulativ|e total |
|00001500| 6f 66 20 35 30 25 20 6f | 66 20 74 68 65 20 65 78 |of 50% o|f the ex|
|00001510| 65 63 75 74 69 6f 6e 20 | 74 69 6d 65 2e 20 50 72 |ecution |time. Pr|
|00001520| 6f 66 69 6c 65 72 73 20 | 61 72 65 20 75 73 75 61 |ofilers |are usua|
|00001530| 6c 6c 79 20 6e 6f 74 20 | 68 69 65 72 61 72 63 68 |lly not |hierarch|
|00001540| 69 63 61 6c 2c 20 73 6f | 20 63 68 69 6c 64 20 66 |ical, so| child f|
|00001550| 75 6e 63 74 69 6f 6e 20 | 74 69 6d 65 20 69 73 20 |unction |time is |
|00001560| 6e 6f 74 20 64 65 74 65 | 72 6d 69 6e 65 64 2e 20 |not dete|rmined. |
|00001570| 20 54 68 65 20 74 68 69 | 72 64 20 6d 61 69 6e 20 | The thi|rd main |
|00001580| 45 20 00 00 91 47 f6 00 | 00 37 e6 00 90 88 98 00 |E ...G..|.7......|
|00001590| 90 4e 2a 00 2b 6a 10 00 | 08 79 0c 00 00 00 e0 00 |.N*.+j..|.y......|
|000015a0| 00 37 e6 00 2c e8 1e 00 | 29 04 dc 00 91 43 bc 00 |.7..,...|)....C..|
|000015b0| 00 00 36 00 00 00 00 00 | 01 ff 36 00 00 00 01 fd |..6.....|..6.....|
|000015c0| 00 08 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000015d0| 00 80 32 62 94 00 00 00 | 00 00 00 00 48 00 48 02 |..2b....|....H.H.|
|000015e0| b8 02 42 80 00 80 00 80 | 00 80 00 00 00 00 00 80 |..B.....|........|
|000015f0| 32 62 94 00 00 00 00 00 | 27 37 34 02 00 00 36 00 |2b......|'74...6.|
|00001600| 00 00 00 00 00 00 00 00 | 00 ff 00 00 00 00 00 00 |........|........|
|00001610| 00 00 00 00 00 00 00 00 | 00 00 03 00 a0 67 3e b8 |........|.....g>.|
|00001620| 02 20 34 1f 4c df 00 03 | 00 00 00 00 00 00 00 00 |. 4.L...|........|
|00001630| 00 00 00 00 00 8c 02 b8 | 00 48 02 d2 02 42 80 00 |........|.H...B..|
|00001640| 80 00 80 00 80 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001650| 00 00 00 27 37 1c 01 81 | 00 0c 00 00 00 00 00 00 |...'7...|........|
|00001660| 00 00 00 00 ff 00 00 00 | 02 00 00 00 00 00 02 ff |........|........|
|00001670| 36 00 00 00 01 fd 00 08 | 40 00 00 00 00 00 00 9e |6.......|@.......|
|00001680| 76 65 6e 74 20 6c 6f 6f | 70 20 61 73 20 75 73 69 |vent loo|p as usi|
|00001690| 6e 67 20 39 30 2b 25 20 | 6f 66 20 74 68 65 20 43 |ng 90+% |of the C|
|000016a0| 50 55 20 74 69 6d 65 20 | 6f 66 20 74 68 65 20 70 |PU time |of the p|
|000016b0| 72 6f 67 72 61 6d 20 69 | 66 20 74 68 65 20 70 72 |rogram i|f the pr|
|000016c0| 6f 66 69 6c 65 72 20 72 | 75 6e 73 20 66 6f 72 20 |ofiler r|uns for |
|000016d0| 61 6e 79 20 72 65 61 6c | 20 6c 65 6e 67 74 68 20 |any real| length |
|000016e0| 6f 66 20 74 69 6d 65 2e | 0d 54 68 65 20 73 65 63 |of time.|.The sec|
|000016f0| 6f 6e 64 20 6d 65 74 68 | 6f 64 20 69 73 20 74 6f |ond meth|od is to|
|00001700| 20 61 63 74 75 61 6c 6c | 79 20 75 73 65 20 74 68 | actuall|y use th|
|00001710| 65 20 73 6f 75 72 63 65 | 20 63 6f 64 65 20 62 65 |e source| code be|
|00001720| 69 6e 67 20 65 78 61 6d | 69 6e 65 64 20 6f 6e 20 |ing exam|ined on |
|00001730| 61 20 73 6c 6f 77 20 6d | 61 63 68 69 6e 65 2e 20 |a slow m|achine. |
|00001740| 54 68 65 20 74 77 6f 20 | 62 65 73 74 20 6d 61 63 |The two |best mac|
|00001750| 68 69 6e 65 73 20 74 6f | 20 74 65 73 74 20 63 6f |hines to| test co|
|00001760| 64 65 20 6f 6e 20 61 72 | 65 20 74 68 65 20 4d 61 |de on ar|e the Ma|
|00001770| 63 69 6e 74 6f 73 68 20 | 43 6c 61 73 73 69 63 20 |cintosh |Classic |
|00001780| 28 6f 72 20 50 6c 75 73 | 29 20 61 6e 64 20 74 68 |(or Plus|) and th|
|00001790| 65 20 4c 43 2e 20 54 68 | 65 20 43 6c 61 73 73 69 |e LC. Th|e Classi|
|000017a0| 63 20 69 73 20 74 68 65 | 20 73 6c 6f 77 65 73 74 |c is the| slowest|
|000017b0| 20 6f 66 20 74 68 65 20 | 6d 61 63 68 69 6e 65 73 | of the |machines|
|000017c0| 20 63 75 72 72 65 6e 74 | 6c 79 20 61 76 61 69 6c | current|ly avail|
|000017d0| 61 62 6c 65 2c 20 77 68 | 69 6c 65 20 74 68 65 20 |able, wh|ile the |
|000017e0| 4c 43 20 70 72 6f 76 69 | 64 65 73 20 43 6f 6c 6f |LC provi|des Colo|
|000017f0| 72 20 51 75 69 63 6b 44 | 72 61 77 2c 20 77 68 69 |r QuickD|raw, whi|
|00001800| 63 68 20 63 61 6e 20 68 | 61 76 65 20 61 20 70 72 |ch can h|ave a pr|
|00001810| 6f 66 6f 75 6e 64 20 65 | 66 66 65 63 74 20 6f 6e |ofound e|ffect on|
|00001820| 20 74 68 65 20 64 72 61 | 77 69 6e 67 20 73 70 65 | the dra|wing spe|
|00001830| 65 64 20 6f 66 20 61 20 | 70 72 6f 67 72 61 6d 2e |ed of a |program.|
|00001840| 0d 42 79 20 61 63 74 75 | 61 6c 6c 79 20 75 73 69 |.By actu|ally usi|
|00001850| 6e 67 20 74 68 65 20 63 | 6f 64 65 2c 20 69 74 20 |ng the c|ode, it |
|00001860| 69 73 20 6d 75 63 68 20 | 65 61 73 69 65 72 20 74 |is much |easier t|
|00001870| 6f 20 67 65 74 20 61 20 | 66 65 65 6c 20 66 6f 72 |o get a |feel for|
|00001880| 00 00 78 1c 00 00 02 00 | 00 83 00 c3 00 86 00 c2 |..x.....|........|
|00001890| 00 1a 01 00 00 1b 00 b9 | 00 09 01 00 00 0a 01 00 |........|........|
|000018a0| 00 1e 00 fd 00 0c 01 00 | 00 0d 01 00 00 26 00 f6 |........|.....&..|
|000018b0| 00 23 00 dd 00 24 01 00 | 00 29 00 ea 00 10 01 00 |.#...$..|.)......|
|000018c0| 00 27 00 81 00 2c 00 98 | 00 33 00 f0 00 13 01 00 |.'...,..|.3......|
|000018d0| 00 14 01 00 00 15 01 00 | 00 3a 01 00 00 85 00 01 |........|.:......|
|000018e0| 00 17 01 00 00 18 01 00 | 00 45 00 e6 00 7d 00 a4 |........|.E...}..|
|000018f0| 00 1c 01 00 00 1d 01 00 | 00 3d 00 fe 00 1f 01 00 |........|.=......|
|00001900| 00 20 01 00 00 21 01 00 | 00 22 01 00 00 3f 00 ff |. ...!..|."...?..|
|00001910| 00 40 00 ff 00 25 01 00 | 00 88 00 ff 00 89 00 f3 |.@...%..|........|
|00001920| 00 28 01 00 00 4b 00 fe | 00 2a 01 00 00 2b 01 00 |.(...K..|.*...+..|
|00001930| 00 5c 00 fe 00 2d 01 00 | 00 2e 01 00 00 2f 01 00 |.\...-..|...../..|
|00001940| 00 30 01 00 00 31 01 00 | 00 32 01 00 00 8a 00 fd |.0...1..|.2......|
|00001950| 00 34 01 00 00 35 01 00 | 00 36 01 00 00 37 01 00 |.4...5..|.6...7..|
|00001960| 00 38 01 00 00 39 01 00 | 00 8b 00 81 00 90 00 97 |.8...9..|........|
|00001970| 00 3b 01 00 00 3c 01 00 | 00 44 00 ad 00 3e 00 94 |.;...<..|.D...>..|
|00001980| 72 20 64 69 73 63 75 73 | 73 65 73 20 73 6f 6d 65 |r discus|ses some|
|00001990| 20 63 6f 6d 6d 6f 6e 20 | 63 6f 64 69 6e 67 20 73 | common |coding s|
|000019a0| 74 79 6c 65 73 20 61 6e | 64 20 6f 70 74 69 6d 69 |tyles an|d optimi|
|000019b0| 7a 61 74 69 6f 6e 73 20 | 77 68 69 63 68 20 63 61 |zations |which ca|
|000019c0| 6e 20 62 65 20 75 73 65 | 64 20 77 69 74 68 20 74 |n be use|d with t|
|000019d0| 68 65 20 6d 6f 73 74 20 | 70 6f 70 75 6c 61 72 20 |he most |popular |
|000019e0| 63 6f 6d 70 69 6c 65 72 | 73 20 74 6f 64 61 79 20 |compiler|s today |
|000019f0| 28 54 48 49 4e 4b 20 43 | 2c 20 54 48 49 4e 4b 20 |(THINK C|, THINK |
|00001a00| 50 61 73 63 61 6c 2c 20 | 4d 50 57 20 43 2c 20 4d |Pascal, |MPW C, M|
|00001a10| 50 57 20 43 2b 2b 2c 20 | 61 6e 64 20 4d 50 57 20 |PW C++, |and MPW |
|00001a20| 50 61 73 63 61 6c 29 2e | 0d 0c 49 6e 74 72 6f 64 |Pascal).|..Introd|
|00001a30| 75 63 74 69 6f 6e 0d 41 | 73 20 63 6f 6d 70 75 74 |uction.A|s comput|
|00001a40| 65 72 73 20 61 6e 64 20 | 63 6f 6d 70 75 74 65 72 |ers and |computer|
|00001a50| 20 73 63 69 65 6e 63 65 | 20 68 61 76 65 20 6d 61 | science| have ma|
|00001a60| 74 75 72 65 64 2c 20 6e | 65 77 65 72 2c 20 62 65 |tured, n|ewer, be|
|00001a70| 74 74 65 72 2c 20 61 6e | 64 20 6d 6f 72 65 20 63 |tter, an|d more c|
|00001a80| 6f 6d 70 6c 65 78 20 70 | 72 6f 67 72 61 6d 6d 69 |omplex p|rogrammi|
|00001a90| 6e 67 20 70 61 72 61 64 | 69 67 6d 73 05 20 68 61 |ng parad|igms. ha|
|00001aa0| 76 65 20 63 6f 6d 65 20 | 69 6e 74 6f 20 76 6f 67 |ve come |into vog|
|00001ab0| 75 65 2c 20 6d 6f 73 74 | 20 6e 6f 74 61 62 6c 79 |ue, most| notably|
|00001ac0| 20 6f 62 6a 65 63 74 2d | 6f 72 69 65 6e 74 65 64 | object-|oriented|
|00001ad0| 20 70 72 6f 67 72 61 6d | 6d 69 6e 67 2e 20 55 6e | program|ming. Un|
|00001ae0| 66 6f 72 74 75 6e 61 74 | 65 6c 79 2c 20 74 68 65 |fortunat|ely, the|
|00001af0| 20 6e 65 77 20 70 72 6f | 67 72 61 6d 6d 69 6e 67 | new pro|gramming|
|00001b00| 20 6d 6f 64 65 6c 73 20 | 6c 65 61 64 20 74 6f 20 | models |lead to |
|00001b10| 63 6f 64 65 20 77 68 69 | 63 68 20 69 73 20 69 6e |code whi|ch is in|
|00001b20| 68 65 72 65 6e 74 6c 79 | 20 6c 65 73 73 20 65 66 |herently| less ef|
|00001b30| 66 69 63 69 65 6e 74 20 | 74 20 6e 65 77 20 70 72 |ficient |t new pr|
|00001b40| 6f 67 72 61 6d 6d 69 6e | 67 20 6d 6f 64 65 6c 73 |ogrammin|g models|
|00001b50| 20 6c 65 61 64 20 20 63 | 6f 64 65 20 77 68 69 63 | lead c|ode whic|
|00001b60| 68 20 69 73 20 69 6e 68 | 65 72 65 6e 74 6c 79 20 |h is inh|erently |
|00001b70| 6c 65 73 73 20 65 66 66 | 69 63 69 65 6e 74 20 74 |less eff|icient t|
|00001b80| 73 20 6d 65 61 6e 73 20 | 74 68 61 74 20 66 6f 72 |s means |that for|
|00001b90| 20 65 76 65 72 79 20 54 | 6f 6f 6c 62 6f 78 20 74 | every T|oolbox t|
|00001ba0| 72 61 70 2c 20 74 68 65 | 72 65 20 69 73 20 61 6e |rap, the|re is an|
|00001bb0| 20 69 6e 64 65 78 65 64 | 20 6c 6f 6f 6b 75 70 20 | indexed| lookup |
|00001bc0| 69 6e 74 6f 20 74 68 65 | 20 64 69 73 70 61 74 63 |into the| dispatc|
|00001bd0| 68 20 74 61 62 6c 65 2c | 20 74 68 65 6e 20 61 20 |h table,| then a |
|00001be0| 4a 4d 50 20 74 6f 20 74 | 68 65 20 61 63 74 75 61 |JMP to t|he actua|
|00001bf0| 6c 20 74 72 61 70 2e 20 | 46 6f 72 20 6d 6f 73 74 |l trap. |For most|
|00001c00| 20 74 72 61 70 73 2c 20 | 74 68 65 20 6f 76 65 72 | traps, |the over|
|00001c10| 68 65 61 64 20 6f 66 20 | 74 68 69 73 20 63 61 6c |head of |this cal|
|00001c20| 6c 20 69 73 20 69 6e 73 | 69 67 6e 69 66 69 63 61 |l is ins|ignifica|
|00001c30| 6e 74 2c 20 64 75 65 20 | 74 6f 20 74 68 65 20 6e |nt, due |to the n|
|00001c40| 75 6d 62 65 72 20 6f 66 | 20 6d 61 63 68 69 6e 65 |umber of| machine|
|00001c50| 20 69 6e 73 74 72 75 63 | 74 69 6f 6e 73 20 75 73 | instruc|tions us|
|00001c60| 65 64 20 69 6e 20 74 68 | 65 20 61 63 74 75 61 6c |ed in th|e actual|
|00001c70| 20 74 72 61 70 2e 20 54 | 68 65 72 65 20 61 72 65 | trap. T|here are|
|00001c80| 20 61 20 66 65 77 20 74 | 72 61 70 73 20 77 68 69 | a few t|raps whi|
|00001c90| 63 68 20 61 72 65 20 76 | 65 72 79 20 73 68 6f 72 |ch are v|ery shor|
|00001ca0| 74 2c 20 68 6f 77 65 76 | 65 72 2c 20 77 68 65 72 |t, howev|er, wher|
|00001cb0| 65 20 74 68 65 20 74 72 | 61 70 20 64 69 73 70 61 |e the tr|ap dispa|
|00001cc0| 74 63 68 65 72 20 6d 65 | 63 68 61 6e 69 73 6d 20 |tcher me|chanism |
|00001cd0| 69 73 20 61 63 74 75 61 | 6c 6c 79 20 73 6c 6f 77 |is actua|lly slow|
|00001ce0| 65 72 20 74 68 61 6e 20 | 74 68 65 20 6f 70 65 72 |er than |the oper|
|00001cf0| 61 74 69 6f 6e 20 62 65 | 69 6e 67 20 70 65 72 66 |ation be|ing perf|
|00001d00| 6f 72 6d 65 64 2e 20 53 | 65 74 52 65 63 74 20 61 |ormed. S|etRect a|
|00001d10| 6e 64 20 53 65 74 50 74 | 20 61 72 65 20 74 77 6f |nd SetPt| are two|
|00001d20| 20 65 78 61 6d 70 6c 65 | 73 20 6f 66 20 74 68 65 | example|s of the|
|00001d30| 73 65 2e 0d 54 68 65 20 | 61 63 74 75 61 6c 20 63 |se..The |actual c|
|00001d40| 6f 64 65 20 6e 65 65 64 | 65 64 20 66 6f 72 20 53 |ode need|ed for S|
|00001d50| 65 74 52 65 63 74 20 69 | 73 20 6f 6e 6c 79 20 66 |etRect i|s only f|
|00001d60| 6f 75 72 20 69 6e 73 74 | 72 75 63 74 69 6f 6e 73 |our inst|ructions|
|00001d70| 2e 20 28 54 68 69 73 20 | 65 78 63 6c 75 64 65 73 |. (This |excludes|
|00001d80| 72 65 20 65 66 66 69 63 | 69 65 6e 74 20 63 6f 6d |re effic|ient com|
|00001d90| 70 69 6c 65 72 73 20 68 | 61 76 65 20 62 65 65 6e |pilers h|ave been|
|00001da0| 20 63 72 65 61 74 65 64 | 2e 20 54 68 65 73 65 20 | created|. These |
|00001db0| 63 6f 6d 70 69 6c 65 72 | 73 20 63 61 6e 20 6f 70 |compiler|s can op|
|00001dc0| 74 69 6d 69 7a 65 20 74 | 68 65 20 6f 62 6a 65 63 |timize t|he objec|
|00001dd0| 74 20 63 6f 64 65 20 67 | 65 6e 65 72 61 74 65 64 |t code g|enerated|
|00001de0| 20 74 6f 20 61 20 63 65 | 72 74 61 69 6e 20 64 65 | to a ce|rtain de|
|00001df0| 67 72 65 65 2c 20 64 65 | 70 65 6e 64 69 6e 67 20 |gree, de|pending |
|00001e00| 75 70 6f 6e 20 6f 70 74 | 69 6f 6e 73 20 73 65 6c |upon opt|ions sel|
|00001e10| 65 63 74 65 64 20 62 79 | 20 74 68 65 20 70 72 6f |ected by| the pro|
|00001e20| 67 72 61 6d 6d 65 72 2e | 20 4d 61 6e 79 20 70 72 |grammer.| Many pr|
|00001e30| 6f 67 72 61 6d 6d 65 72 | 73 20 68 61 76 65 20 63 |ogrammer|s have c|
|00001e40| 6f 6d 65 20 74 6f 20 62 | 65 6c 69 65 76 65 20 74 |ome to b|elieve t|
|00001e50| 68 61 74 20 74 68 65 20 | 63 6f 6d 70 69 6c 65 72 |hat the |compiler|
|00001e60| 20 77 69 6c 6c 20 6d 61 | 6b 65 20 74 68 65 69 72 | will ma|ke their|
|00001e70| 20 63 6f 64 65 20 62 65 | 74 74 65 72 20 65 72 20 | code be|tter er |
|00001e80| 6e 6f 74 20 61 66 66 65 | 63 74 20 61 63 74 75 61 |not affe|ct actua|
|00001e90| 6c 20 63 6f 64 65 20 73 | 70 65 65 64 2c 20 62 75 |l code s|peed, bu|
|00001ea0| 74 20 63 61 6e 20 61 66 | 66 65 63 74 20 74 68 65 |t can af|fect the|
|00001eb0| 6d 20 6d 65 6d 6f 72 79 | 20 73 69 7a 65 20 6e 65 |m memory| size ne|
|00001ec0| 65 64 65 64 20 66 6f 72 | 20 74 68 65 20 63 6f 64 |eded for| the cod|
|00001ed0| 65 2e 20 4f 70 74 69 6d | 69 7a 65 20 74 68 65 20 |e. Optim|ize the |
|00001ee0| 76 61 72 69 61 62 6c 65 | 20 64 65 63 6c 61 72 61 |variable| declara|
|00001ef0| 74 69 6f 6e 73 2e 20 4c | 65 61 72 6e 20 74 68 65 |tions. L|earn the|
|00001f00| 20 73 69 7a 65 20 6f 66 | 20 63 6f 6d 6d 6f 6e 20 | size of| common |
|00001f10| 4d 61 63 69 6e 74 6f 73 | 68 20 73 74 72 75 63 74 |Macintos|h struct|
|00001f20| 75 72 65 73 20 61 6e 64 | 20 74 79 70 65 73 20 61 |ures and| types a|
|00001f30| 6e 64 20 6b 65 65 70 20 | 74 68 65 6d 20 69 6e 20 |nd keep |them in |
|00001f40| 6d 69 6e 64 20 77 68 65 | 6e 20 64 65 66 69 6e 69 |mind whe|n defini|
|00001f50| 6e 67 20 74 68 65 20 6f | 72 64 65 72 20 6f 66 20 |ng the o|rder of |
|00001f60| 79 6f 75 72 20 76 61 72 | 69 61 62 6c 65 73 2e 0d |your var|iables..|
|00001f70| 45 76 65 72 79 20 73 74 | 72 75 63 74 75 72 65 20 |Every st|ructure |
|00001f80| 77 69 6c 6c 20 62 65 20 | 61 6c 6c 6f 63 61 74 65 |will be |allocate|
|00001f90| 64 20 6f 6e 20 61 20 77 | 6f 72 64 20 62 6f 75 6e |d on a w|ord boun|
|00001fa0| 64 61 72 79 20 28 65 76 | 65 6e 6c 79 20 64 69 76 |dary (ev|enly div|
|00001fb0| 69 73 69 62 6c 65 20 62 | 79 20 32 29 2e 20 53 6f |isible b|y 2). So|
|00001fc0| 6d 65 20 63 6f 6d 70 69 | 6c 65 72 73 20 77 69 6c |me compi|lers wil|
|00001fd0| 6c 20 72 65 2d 61 72 72 | 61 6e 67 65 20 42 6f 6f |l re-arr|ange Boo|
|00001fe0| 6c 65 61 6e 20 61 6e 64 | 20 63 68 61 72 61 63 74 |lean and| charact|
|00001ff0| 65 72 20 76 61 72 69 61 | 62 6c 65 73 20 74 6f 20 |er varia|bles to |
|00002000| 74 61 6b 65 20 75 70 20 | 6c 65 73 73 20 73 70 61 |take up |less spa|
|00002010| 63 65 20 6f 6e 20 74 68 | 65 20 73 74 61 63 6b 2c |ce on th|e stack,|
|00002020| 20 62 75 74 20 6e 6f 74 | 20 61 6c 6c 20 77 69 6c | but not| all wil|
|00002030| 6c 2e 20 20 42 79 20 6b | 65 65 70 69 6e 67 20 73 |l. By k|eeping s|
|00002040| 68 6f 72 74 20 76 61 72 | 69 61 62 6c 65 73 20 67 |hort var|iables g|
|00002050| 72 6f 75 70 65 64 20 74 | 6f 20 74 61 6b 65 20 32 |rouped t|o take 2|
|00002060| 20 6f 72 20 34 20 62 79 | 74 65 20 63 68 75 6e 6b | or 4 by|te chunk|
|00002070| 73 20 6f 66 20 61 6c 6c | 6f 63 61 74 69 6f 6e 2c |s of all|ocation,|
|00002080| 20 79 6f 75 20 63 61 6e | 20 63 61 75 73 65 20 6c | you can| cause l|
|00002090| 65 73 73 20 73 74 61 63 | 6b 20 66 72 61 67 6d 65 |ess stac|k fragme|
|000020a0| 6e 74 61 74 69 6f 6e 2c | 20 61 6e 64 20 73 6c 69 |ntation,| and sli|
|000020b0| 67 68 74 6c 79 20 6c 65 | 73 73 20 6d 65 6d 6f 72 |ghtly le|ss memor|
|000020c0| 79 20 75 73 61 67 65 2e | 0d 54 68 65 20 73 61 6d |y usage.|.The sam|
|000020d0| 65 20 61 72 67 75 6d 65 | 6e 74 20 61 70 70 6c 69 |e argume|nt appli|
|000020e0| 65 73 20 65 76 65 6e 20 | 6d 6f 72 65 20 73 6f 20 |es even |more so |
|000020f0| 74 6f 20 70 61 72 61 6d | 65 74 65 72 73 20 70 61 |to param|eters pa|
|00002100| 73 73 65 64 20 6f 6e 20 | 74 68 65 20 73 74 61 63 |ssed on |the stac|
|00002110| 6b 2e 20 49 66 20 79 6f | 75 20 63 61 6e 20 64 65 |k. If yo|u can de|
|00002120| 66 69 6e 65 20 72 6f 75 | 74 69 6e 65 20 63 61 6c |fine rou|tine cal|
|00002130| 6c 69 6e 67 20 73 65 71 | 75 65 6e 63 65 73 20 77 |ling seq|uences w|
|00002140| 68 69 63 68 20 70 6c 61 | 63 65 20 61 6c 6c 20 74 |hich pla|ce all t|
|00002150| 68 65 20 63 68 61 72 61 | 63 74 65 72 20 6f 72 20 |he chara|cter or |
|00002160| 42 6f 6f 6c 65 61 6e 20 | 76 61 6c 75 65 73 20 74 |Boolean |values t|
|00002170| 6f 67 65 74 68 65 72 2c | 20 73 74 61 63 6b 20 75 |ogether,| stack u|
|00002180| 73 61 67 65 20 63 61 6e | 20 62 65 20 6d 69 6e 69 |sage can| be mini|
|00002190| 6d 69 7a 65 64 2e 20 49 | 66 20 20 79 6f 75 20 70 |mized. I|f you p|
|000021a0| 61 73 73 20 61 20 42 6f | 6f 6c 65 61 6e 2c 20 73 |ass a Bo|olean, s|
|000021b0| 68 6f 72 74 2c 20 20 61 | 6e 64 20 42 6f 6f 6c 65 |hort, a|nd Boole|
|000021c0| 61 6e 20 74 6f 20 61 20 | 72 6f 75 74 69 6e 65 2c |an to a |routine,|
|000021d0| 20 73 69 78 20 62 79 74 | 65 73 20 61 72 65 20 70 | six byt|es are p|
|000021e0| 6c 61 63 65 64 20 6f 6e | 20 74 68 65 20 73 74 61 |laced on| the sta|
|000021f0| 63 6b 2e 20 50 61 73 73 | 69 6e 67 20 61 20 73 68 |ck. Pass|ing a sh|
|00002200| 6f 72 74 2c 20 42 6f 6f | 6c 65 61 6e 2c 20 61 6e |ort, Boo|lean, an|
|00002210| 64 20 42 6f 6f 6c 65 61 | 6e 20 6f 6e 6c 79 20 72 |d Boolea|n only r|
|00002220| 65 71 75 69 72 65 73 20 | 66 6f 75 72 20 62 79 65 |equires |four bye|
|00002230| 73 20 6f 66 20 73 74 61 | 63 6b 20 73 70 61 63 65 |s of sta|ck space|
|00002240| 2e 20 57 68 69 6c 65 20 | 74 77 6f 20 62 79 74 65 |. While |two byte|
|00002250| 73 20 6d 61 79 20 6e 6f | 74 20 73 65 65 6d 20 6c |s may no|t seem l|
|00002260| 69 6b 65 20 6d 75 63 68 | 2c 20 6f 6e 20 61 20 72 |ike much|, on a r|
|00002270| 65 63 75 72 73 69 76 65 | 20 72 6f 75 74 69 6e 65 |ecursive| routine|
|00002280| 6c 79 20 61 6e 79 20 70 | 72 6f 6a 65 63 74 20 63 |ly any p|roject c|
|00002290| 61 6e 20 62 65 6e 65 66 | 69 74 20 66 72 6f 6d 20 |an benef|it from |
|000022a0| 61 70 70 6c 69 65 64 20 | 6f 70 74 69 6d 69 7a 61 |applied |optimiza|
|000022b0| 74 69 6f 6e 2c 20 61 6e | 64 20 67 61 69 6e 20 73 |tion, an|d gain s|
|000022c0| 6f 6d 65 20 73 70 65 65 | 64 20 61 6e 64 20 75 73 |ome spee|d and us|
|000022d0| 65 72 20 70 65 72 66 6f | 72 6d 61 6e 63 65 20 69 |er perfo|rmance i|
|000022e0| 6e 63 72 65 61 73 65 73 | 2e 0d 41 20 4e 6f 74 65 |ncreases|..A Note|
|000022f0| 20 41 62 6f 75 74 20 74 | 68 65 20 4c 61 6e 67 75 | About t|he Langu|
|00002300| 61 67 65 73 0d 54 68 65 | 20 6c 61 6e 67 75 61 67 |ages.The| languag|
|00002310| 65 20 75 73 65 64 20 69 | 6e 20 74 68 69 73 20 70 |e used i|n this p|
|00002320| 61 70 65 72 20 69 73 20 | 70 72 69 6d 61 72 69 6c |aper is |primaril|
|00002330| 79 20 43 20 61 6e 64 20 | 43 2b 2b 2e 20 54 68 65 |y C and |C++. The|
|00002340| 72 65 20 61 72 65 20 61 | 6c 73 6f 20 73 6f 6d 65 |re are a|lso some|
|00002350| 20 74 69 70 73 20 66 6f | 72 20 50 61 73 61 6c 20 | tips fo|r Pasal |
|00002360| 70 72 6f 67 72 61 6d 6d | 65 72 73 2e 20 54 68 65 |programm|ers. The|
|00002370| 20 64 65 76 65 6c 6f 70 | 6d 65 6e 74 20 73 79 73 | develop|ment sys|
|00002380| 63 61 6c 20 70 72 6f 67 | 72 61 6d 6d 65 72 73 2e |cal prog|rammers.|
|00002390| 20 54 68 65 20 64 65 76 | 65 6c 6f 70 6d 65 6e 74 | The dev|elopment|
|000023a0| 20 73 79 73 74 65 6d 73 | 20 61 6e 64 20 63 6f 6d | systems| and com|
|000023b0| 70 69 6c 65 72 73 20 75 | 73 65 64 20 66 6f 72 20 |pilers u|sed for |
|000023c0| 67 65 6e 65 72 61 74 69 | 6e 67 20 61 6e 64 20 63 |generati|ng and c|
|000023d0| 6f 6d 70 61 72 69 6e 67 | 20 63 6f 64 65 20 61 72 |omparing| code ar|
|000023e0| 65 20 4d 50 57 20 33 2e | 32 20 28 43 2c 20 43 2b |e MPW 3.|2 (C, C+|
|000023f0| 2b 2c 20 61 6e 64 20 50 | 61 73 63 61 6c 29 2c 20 |+, and P|ascal), |
|00002400| 54 48 49 4e 4b 20 43 20 | 35 2e 30 2e 32 20 61 6e |THINK C |5.0.2 an|
|00002410| 64 20 54 48 49 4e 4b 20 | 50 61 73 63 61 6c 20 34 |d THINK |Pascal 4|
|00002420| 2e 30 2e 31 2e 20 55 6c | 74 72 61 53 6c 69 6d 46 |.0.1. Ul|traSlimF|
|00002430| 61 73 74 20 77 61 73 20 | 75 73 65 64 20 75 6e 64 |ast was |used und|
|00002440| 65 72 20 4d 50 57 20 74 | 6f 20 67 65 6e 65 72 61 |er MPW t|o genera|
|00002450| 74 65 20 73 6f 75 72 63 | 65 2f 61 73 73 65 6d 62 |te sourc|e/assemb|
|00002460| 6c 79 20 6c 69 73 74 69 | 6e 67 73 20 66 6f 72 20 |ly listi|ngs for |
|00002470| 63 6f 6d 70 61 72 69 73 | 6f 6e 73 20 77 68 69 6c |comparis|ons whil|
|00002480| 65 6e 74 20 70 6c 61 63 | 65 73 20 28 69 6e 20 74 |ent plac|es (in t|
|00002490| 68 65 20 73 61 6d 65 20 | 72 6f 75 74 69 6e 65 29 |he same |routine)|
|000024a0| 20 77 69 74 68 20 74 68 | 65 20 73 61 6d 65 20 64 | with th|e same d|
|000024b0| 61 74 61 3f 20 43 6f 75 | 6c 64 20 74 68 65 20 77 |ata? Cou|ld the w|
|000024c0| 6f 72 6b 20 64 6f 6e 65 | 20 62 65 20 70 72 65 73 |ork done| be pres|
|000024d0| 65 72 76 65 64 20 69 6e | 20 61 20 6c 6f 63 61 6c |erved in| a local|
|000024e0| 20 76 61 72 69 61 62 6c | 65 20 75 6e 74 69 6c 20 | variabl|e until |
|000024f0| 69 74 20 69 73 20 6e 65 | 65 64 65 64 20 61 67 61 |it is ne|eded aga|
|00002500| 69 6e 3f 20 49 66 20 73 | 6f 2c 20 6f 70 74 69 6d |in? If s|o, optim|
|00002510| 69 7a 65 20 69 74 21 0d | 44 75 72 69 6e 67 20 74 |ize it!.|During t|
|00002520| 68 65 20 66 6c 6f 77 20 | 6f 66 20 65 78 65 63 75 |he flow |of execu|
|00002530| 74 69 6f 6e 2c 20 64 6f | 65 73 20 61 20 72 6f 75 |tion, do|es a rou|
|00002540| 74 69 6e 65 20 67 65 74 | 20 63 61 6c 6c 65 64 20 |tine get| called |
|00002550| 72 65 70 65 61 74 65 64 | 6c 79 2c 20 65 73 70 65 |repeated|ly, espe|
|00002560| 63 69 61 6c 6c 79 20 66 | 6f 72 20 64 72 61 77 69 |cially f|or drawi|
|00002570| 6e 67 3f 20 46 6f 72 20 | 69 6e 73 74 61 6e 63 65 |ng? For |instance|
|00002580| 73 65 6d 62 6c 79 20 6c | 61 6e 67 75 61 67 65 20 |sembly l|anguage |
|00002590| 28 72 65 61 64 69 6e 67 | 20 6f 6e 6c 79 29 20 66 |(reading| only) f|
|000025a0| 6f 72 20 62 65 73 74 20 | 72 65 73 75 6c 74 73 2c |or best |results,|
|000025b0| 20 62 75 74 20 67 65 6e | 65 72 61 6c 20 63 61 73 | but gen|eral cas|
|000025c0| 65 20 72 75 6c 65 73 20 | 63 61 6e 20 62 65 20 61 |e rules |can be a|
|000025d0| 70 70 6c 69 65 64 20 62 | 79 20 61 6e 79 62 6f 64 |pplied b|y anybod|
|000025e0| 79 2e 20 53 6f 75 72 63 | 65 20 63 6f 64 65 20 6f |y. Sourc|e code o|
|000025f0| 70 74 69 6d 69 7a 61 74 | 69 6f 6e 2c 20 73 69 6d |ptimizat|ion, sim|
|00002600| 70 6c 79 20 73 74 61 74 | 65 64 2c 20 6d 65 61 6e |ply stat|ed, mean|
|00002610| 73 20 61 64 6a 75 73 74 | 69 6e 67 20 74 68 65 20 |s adjust|ing the |
|00002620| 79 6f 75 72 20 73 6f 75 | 72 63 65 20 63 6f 64 65 |your sou|rce code|
|00002630| 20 74 6f 20 61 73 73 69 | 73 74 20 74 68 65 20 63 | to assi|st the c|
|00002640| 6f 6d 70 69 6c 65 72 20 | 69 6e 20 70 72 6f 64 75 |ompiler |in produ|
|00002650| 63 69 6e 67 20 73 6d 61 | 6c 6c 65 72 2c 20 66 61 |cing sma|ller, fa|
|00002660| 73 74 65 72 20 6f 62 6a | 65 63 74 20 63 6f 64 65 |ster obj|ect code|
|00002670| 2e 20 4e 65 61 72 63 6f | 64 65 2e 20 4e 65 61 72 |. Nearco|de. Near|
|00002680| 65 20 69 73 20 73 6c 6f | 77 2c 20 6f 6e 6c 79 20 |e is slo|w, only |
|00002690| 74 6f 20 66 69 6e 64 20 | 6f 75 74 20 74 68 61 74 |to find |out that|
|000026a0| 20 69 74 20 69 73 20 75 | 73 65 64 20 6c 65 73 73 | it is u|sed less|
|000026b0| 20 66 72 65 71 75 65 6e | 74 6c 79 20 74 68 61 6e | frequen|tly than|
|000026c0| 20 61 20 72 6f 75 74 69 | 6e 65 20 77 68 69 63 68 | a routi|ne which|
|000026d0| 20 69 73 20 76 65 72 79 | 20 69 6e 65 66 66 69 63 | is very| ineffic|
|000026e0| 69 65 6e 74 20 77 68 69 | 63 68 20 77 61 73 6e d5 |ient whi|ch wasn.|
|000026f0| 74 20 65 76 65 6e 20 65 | 78 61 6d 69 6e 65 64 2e |t even e|xamined.|
|00002700| 0d 41 73 20 79 6f 75 20 | 62 65 63 6f 6d 65 20 66 |.As you |become f|
|00002710| 61 6d 69 6c 69 61 72 20 | 77 69 74 68 20 61 6e 64 |amiliar |with and|
|00002720| 20 70 72 61 63 74 69 63 | 65 20 75 73 69 6e 67 20 | practic|e using |
|00002730| 6f 70 74 69 6d 69 7a 69 | 6e 67 20 74 65 63 68 6e |optimizi|ng techn|
|00002740| 69 71 75 65 73 2c 20 74 | 68 65 20 63 6f 64 65 20 |iques, t|he code |
|00002750| 79 6f 75 20 77 72 69 74 | 65 20 6f 6e 20 61 20 64 |you writ|e on a d|
|00002760| 61 69 6c 79 20 62 61 73 | 69 73 20 77 69 6c 6c 20 |aily bas|is will |
|00002770| 69 6d 70 72 6f 76 65 20 | 61 6e 64 0d 2b 09 4c 65 |improve |and.+.Le|
|00002780| 63 63 75 72 2e 20 4d 61 | 6b 65 20 73 75 72 65 20 |ccur. Ma|ke sure |
|00002790| 79 6f 75 20 64 6f 6e d5 | 74 20 61 63 74 69 76 61 |you don.|t activa|
|000027a0| 74 65 20 61 6e 64 20 64 | 65 61 63 74 69 76 61 74 |te and d|eactivat|
|000027b0| 65 20 69 74 65 6d 73 20 | 6f 6e 20 74 68 65 20 73 |e items |on the s|
|000027c0| 63 72 65 65 6e 2e 20 54 | 68 65 20 66 6c 69 63 6b |creen. T|he flick|
|000027d0| 65 72 20 73 68 6f 77 6e | 20 69 73 20 61 6e 6e 6f |er shown| is anno|
|000027e0| 79 69 6e 67 20 61 6e 64 | 20 69 6e 64 69 63 61 74 |ying and| indicat|
|000027f0| 65 73 20 70 6f 6f 72 20 | 71 75 61 6c 69 74 79 20 |es poor |quality |
|00002800| 6f 66 20 63 6f 64 65 2e | 20 47 72 61 70 68 69 63 |of code.| Graphic|
|00002810| 20 6f 70 65 72 61 74 69 | 6f 6e 73 20 61 72 65 20 | operati|ons are |
|00002820| 6f 66 74 65 6e 20 73 6c | 6f 77 2c 20 74 68 61 74 |often sl|ow, that|
|00002830| 20 69 73 20 77 68 79 20 | 74 68 65 20 74 6f 6f 6c | is why |the tool|
|00002840| 62 6f 78 20 68 61 73 20 | 74 68 65 6d 20 6f 70 74 |box has |them opt|
|00002850| 69 6d 69 7a 65 64 2e 20 | 45 76 65 6e 20 73 6f 2c |imized. |Even so,|
|00002860| 20 79 6f 75 20 63 61 6e | d5 74 20 61 66 66 6f 72 | you can|.t affor|
|00002870| 64 20 74 6f 20 64 6f 20 | 74 77 69 63 65 20 61 73 |d to do |twice as|
|00002880| 65 20 4d 61 63 73 62 75 | 67 2c 20 52 65 73 45 64 |e Macsbu|g, ResEd|
|00002890| 69 74 2c 20 61 6e 64 20 | 74 68 65 20 54 48 49 4e |it, and |the THIN|
|000028a0| 4b 20 43 20 64 69 73 61 | 73 73 65 6d 62 6c 65 72 |K C disa|ssembler|
|000028b0| 20 77 65 72 65 20 75 73 | 65 64 20 66 6f 72 20 74 | were us|ed for t|
|000028c0| 68 65 20 54 48 49 4e 4b | 20 70 72 6f 64 75 63 74 |he THINK| product|
|000028d0| 73 2e 05 20 0d 4b 6e 6f | 77 69 6e 67 20 57 68 65 |s.. .Kno|wing Whe|
|000028e0| 6e 20 61 6e 64 20 57 68 | 65 72 65 20 74 6f 20 4f |n and Wh|ere to O|
|000028f0| 70 74 69 6d 69 7a 65 0d | 4a 75 73 74 20 61 73 20 |ptimize.|Just as |
|00002900| 69 6d 70 6f 72 74 61 6e | 74 20 61 73 20 6f 70 74 |importan|t as opt|
|00002910| 69 6d 69 7a 69 6e 67 20 | 73 6f 75 72 63 65 20 63 |imizing |source c|
|00002920| 6f 64 65 2c 20 69 73 20 | 6b 6e 6f 77 69 6e 67 20 |ode, is |knowing |
|00002930| 77 68 65 72 65 20 74 6f | 20 63 6f 6e 63 65 6e 74 |where to| concent|
|00002940| 72 61 74 65 20 6f 6e 20 | 6d 61 6b 69 6e 67 20 6f |rate on |making o|
|00002950| 70 74 69 6d 69 7a 61 74 | 69 6f 6e 73 2e 20 54 68 |ptimizat|ions. Th|
|00002960| 65 72 65 20 61 72 65 20 | 74 77 69 7a 61 74 69 6f |ere are |twizatio|
|00002970| 6e 73 2e 20 54 68 65 72 | 65 20 61 72 65 20 74 77 |ns. Ther|e are tw|
|00002980| 6e 65 65 64 2e 20 44 6f | 6e d5 74 20 72 65 2d 69 |need. Do|n.t re-i|
|00002990| 6e 76 65 6e 74 20 74 68 | 65 20 77 68 65 65 6c 20 |nvent th|e wheel |
|000029a0| 69 66 20 79 6f 75 20 63 | 61 6e 20 68 65 6c 70 20 |if you c|an help |
|000029b0| 69 74 2e 20 45 76 65 6e | 20 74 68 6f 75 67 68 20 |it. Even| though |
|000029c0| 74 68 69 73 20 6d 61 79 | 20 6e 6f 74 20 73 65 65 |this may| not see|
|000029d0| 6d 20 74 6f 20 62 65 20 | 61 6e 20 6f 70 74 69 6d |m to be |an optim|
|000029e0| 69 7a 61 74 69 6f 6e 20 | 69 73 73 75 65 2c 20 69 |ization |issue, i|
|000029f0| 74 20 69 73 2e 20 4c 69 | 62 72 61 72 69 65 73 20 |t is. Li|braries |
|00002a00| 77 68 69 63 68 20 61 72 | 65 20 73 75 70 70 6c 69 |which ar|e suppli|
|00002a10| 65 64 20 77 69 74 68 20 | 63 6f 6d 70 69 6c 65 72 |ed with |compiler|
|00002a20| 73 20 6d 61 79 20 68 61 | 76 65 20 61 6c 72 65 61 |s may ha|ve alrea|
|00002a30| 64 79 20 62 65 65 6e 20 | 6f 70 74 69 6d 69 7a 65 |dy been |optimize|
|00002a40| 64 2e 20 4f 6e 65 20 70 | 6c 61 63 65 20 74 68 69 |d. One p|lace thi|
|00002a50| 73 20 69 73 20 65 73 70 | 65 63 69 61 6c 6c 79 20 |s is esp|ecially |
|00002a60| 74 72 75 65 20 69 73 20 | 69 6e 20 6d 61 74 68 20 |true is |in math |
|00002a70| 6c 69 62 72 61 72 69 65 | 73 2e 20 28 4e 6f 74 65 |librarie|s. (Note|
|00002a80| 20 74 68 61 74 20 6d 61 | 74 68 20 6c 69 62 72 61 | that ma|th libra|
|00002a90| 72 79 20 66 75 6e 63 74 | 69 6f 6e 20 74 69 6d 69 |ry funct|ion timi|
|00002aa0| 6e 67 73 20 6d 61 79 20 | 76 61 72 79 20 64 65 70 |ngs may |vary dep|
|00002ab0| 65 6e 64 69 6e 67 20 75 | 70 6f 6e 20 74 68 65 20 |ending u|pon the |
|00002ac0| 61 63 63 75 72 61 63 79 | 20 6f 66 20 74 68 65 20 |accuracy| of the |
|00002ad0| 72 6f 75 74 69 6e 65 73 | 20 62 65 69 6e 67 20 75 |routines| being u|
|00002ae0| 73 65 64 2e 29 20 49 66 | 20 79 6f 75 20 68 61 76 |sed.) If| you hav|
|00002af0| 65 20 77 72 69 74 74 65 | 6e 20 79 6f 75 72 20 6f |e writte|n your o|
|00002b00| 77 6e 20 76 65 72 73 69 | 6f 6e 20 6f 66 20 61 20 |wn versi|on of a |
|00002b10| 66 75 6e 63 74 69 6f 6e | 2c 20 64 6f 20 61 6e 20 |function|, do an |
|00002b20| 61 63 74 75 61 6c 20 74 | 69 6d 69 6e 67 20 74 65 |actual t|iming te|
|00002b30| 73 74 20 74 6f 20 73 65 | 65 20 77 68 69 63 68 20 |st to se|e which |
|00002b40| 69 73 20 66 61 73 74 65 | 72 2e 20 42 65 20 70 72 |is faste|r. Be pr|
|00002b50| 65 70 61 72 65 64 20 74 | 6f 20 74 68 72 6f 77 20 |epared t|o throw |
|00002b60| 6f 75 74 20 79 6f 75 72 | 20 63 6f 64 65 20 69 66 |out your| code if|
|00002b70| 20 61 20 73 75 70 65 72 | 69 6f 72 20 76 65 72 73 | a super|ior vers|
|00002b80| 41 73 20 79 6f 75 20 62 | 65 63 6f 6d 65 20 66 61 |As you b|ecome fa|
|00002b90| 6d 69 6c 69 61 72 20 77 | 69 74 68 20 61 6e 64 20 |miliar w|ith and |
|00002ba0| 70 72 61 63 74 69 63 65 | 20 75 73 69 6e 67 20 6f |practice| using o|
|00002bb0| 70 74 69 6d 69 7a 69 6e | 67 20 74 65 63 68 6e 69 |ptimizin|g techni|
|00002bc0| 71 75 65 73 2c 20 74 68 | 65 20 63 6f 64 65 20 79 |ques, th|e code y|
|00002bd0| 6f 75 20 77 72 69 74 65 | 20 6f 6e 20 61 20 64 61 |ou write| on a da|
|00002be0| 69 6c 79 20 62 61 73 69 | 73 20 77 69 6c 6c 20 69 |ily basi|s will i|
|00002bf0| 6d 70 72 6f 76 65 20 61 | 6e 64 20 62 65 63 6f 6d |mprove a|nd becom|
|00002c00| 65 20 6d 6f 72 65 20 65 | 66 66 69 63 69 65 6e 74 |e more e|fficient|
|00002c10| 2e 0d 2b 09 4c 65 61 72 | 00 00 00 14 00 00 b3 90 |..+.Lear|........|
|00002c20| 00 0a 00 00 00 00 00 00 | 00 00 67 00 00 00 00 14 |........|..g.....|
|00002c30| 00 00 b5 48 80 32 60 28 | 00 00 0d e1 00 00 0d e1 |...H.2`(|........|
|00002c40| 00 00 00 14 00 00 b5 4c | 00 0a 01 a4 00 00 02 c5 |.......L|........|
|00002c50| 02 68 66 04 00 00 00 14 | 00 00 b3 90 00 0a 00 00 |.hf.....|........|
|00002c60| 00 00 00 00 00 00 01 7c | 00 00 00 14 00 00 b5 48 |.......||.......H|
|00002c70| 80 32 60 28 00 00 0d e0 | 00 00 0d e0 00 00 00 14 |.2`(....|........|
|00002c80| 6f 6e 65 20 6f 66 20 74 | 68 65 20 6d 6f 73 74 20 |one of t|he most |
|00002c90| 66 75 6e 64 61 6d 65 6e | 74 61 6c 20 70 61 72 74 |fundamen|tal part|
|00002ca0| 73 20 6f 66 20 74 68 65 | 20 4d 61 63 69 6e 74 6f |s of the| Macinto|
|00002cb0| 73 68 2c 20 79 65 74 20 | 69 73 20 6f 66 74 65 6e |sh, yet |is often|
|00002cc0| 20 74 68 65 20 6d 6f 73 | 74 20 6d 61 6c 69 67 6e | the mos|t malign|
|00002cd0| 65 64 2e 20 54 68 65 20 | 70 61 72 74 20 6f 66 20 |ed. The |part of |
|00002ce0| 74 68 65 20 6d 65 6d 6f | 72 79 20 6d 61 6e 61 67 |the memo|ry manag|
|00002cf0| 65 72 20 77 68 69 63 68 | 20 63 61 75 73 65 73 20 |er which| causes |
|00002d00| 74 68 65 20 6d 6f 73 74 | 20 67 72 69 65 66 2c 20 |the most| grief, |
|00002d10| 61 72 65 20 68 61 6e 64 | 6c 65 73 2e 20 4d 61 6e |are hand|les. Man|
|00002d20| 79 20 70 72 6f 67 72 61 | 6d 6d 65 72 73 20 61 72 |y progra|mmers ar|
|00002d30| 65 20 70 61 72 61 6e 6f | 69 64 20 61 62 6f 75 74 |e parano|id about|
|00002d40| 20 64 65 2d 72 65 66 65 | 72 65 6e 63 69 6e 67 20 | de-refe|rencing |
|00002d50| 61 20 68 61 6e 64 6c 65 | 2e 20 53 6f 6d 65 20 77 |a handle|. Some w|
|00002d60| 69 6c 6c 20 61 6c 77 61 | 79 73 20 6c 6f 63 6b 20 |ill alwa|ys lock |
|00002d70| 61 20 68 61 6e 64 6c 65 | 20 62 65 66 6f 72 65 20 |a handle| before |
|00002d80| 75 73 69 6e 67 20 69 74 | 20 69 6e 20 61 6e 79 20 |using it| in any |
|00002d90| 77 61 79 2e 20 54 68 69 | 73 20 69 73 20 76 65 72 |way. Thi|s is ver|
|00002da0| 79 20 69 6e 65 66 66 69 | 63 69 65 6e 74 20 61 6e |y ineffi|cient an|
|00002db0| 64 20 77 61 73 74 65 66 | 75 6c 20 6f 66 20 43 50 |d wastef|ul of CP|
|00002dc0| 55 20 74 69 6d 65 2e 0d | 48 61 6e 64 6c 65 73 20 |U time..|Handles |
|00002dd0| 73 68 6f 75 6c 64 20 6f | 6e 6c 79 20 62 65 20 6c |should o|nly be l|
|00002de0| 6f 63 6b 65 64 20 77 68 | 65 6e 20 74 68 65 20 64 |ocked wh|en the d|
|00002df0| 61 74 61 20 69 6e 20 74 | 68 65 20 68 61 6e 64 6c |ata in t|he handl|
|00002e00| 65 20 6d 61 79 20 6d 6f | 76 65 20 64 75 72 69 6e |e may mo|ve durin|
|00002e10| 67 20 61 6e 20 6f 70 65 | 72 61 74 69 6f 6e 20 77 |g an ope|ration w|
|00002e20| 68 69 63 68 20 75 73 65 | 73 20 74 68 65 20 64 61 |hich use|s the da|
|00002e30| 74 61 2e 20 54 68 69 73 | 20 74 79 70 69 63 61 6c |ta. This| typical|
|00002e40| 6c 79 20 6d 65 61 6e 73 | 20 74 68 61 74 20 69 66 |ly means| that if|
|00002e50| 20 79 6f 75 20 61 72 65 | 20 64 65 2d 72 65 66 65 | you are| de-refe|
|00002e60| 72 65 6e 63 69 6e 67 20 | 61 20 68 61 6e 64 6c 65 |rencing |a handle|
|00002e70| 20 6f 6e 20 61 20 74 6f | 6f 6c 62 6f 78 20 63 61 | on a to|olbox ca|
|00002e80| 6c 6c 20 28 6f 72 20 6f | 6e 65 20 6f 66 20 79 6f |ll (or o|ne of yo|
|00002e90| 75 72 20 6f 77 6e 20 72 | 6f 75 74 69 6e 65 73 20 |ur own r|outines |
|00002ea0| 77 68 69 63 68 20 6d 61 | 6b 65 73 20 61 20 74 6f |which ma|kes a to|
|00002eb0| 6f 6c 62 6f 78 20 63 61 | 6c 6c 29 20 77 68 69 63 |olbox ca|ll) whic|
|00002ec0| 68 20 6d 6f 76 65 73 20 | 6d 65 6d 6f 72 79 2c 20 |h moves |memory, |
|00002ed0| 74 68 65 20 68 61 6e 64 | 6c 65 20 6e 65 65 64 73 |the hand|le needs|
|00002ee0| 20 74 6f 20 62 65 20 6c | 6f 63 6b 65 64 2e 20 45 | to be l|ocked. E|
|00002ef0| 61 63 68 20 76 6f 6c 75 | 6d 65 20 6f 66 20 49 6e |ach volu|me of In|
|00002f00| 73 69 64 65 20 4d 61 63 | 69 6e 74 6f 73 68 20 68 |side Mac|intosh h|
|00002f10| 61 73 20 61 6e 20 61 70 | 70 65 6e 64 69 78 20 6c |as an ap|pendix l|
|00002f20| 69 73 74 69 6e 67 20 61 | 6c 6c 20 74 68 65 20 72 |isting a|ll the r|
|00002f30| 6f 75 74 69 6e 65 73 20 | 69 6e 20 74 68 61 74 20 |outines |in that |
|00002f40| 76 6f 6c 75 6d 65 20 77 | 68 69 63 68 20 6d 61 79 |volume w|hich may|
|00002f50| 20 6d 6f 76 65 20 6f 72 | 20 70 75 72 67 65 20 6d | move or| purge m|
|00002f60| 65 6d 6f 72 79 2e 20 54 | 68 65 72 65 20 69 73 20 |emory. T|here is |
|00002f70| 61 6c 73 6f 20 61 20 73 | 65 63 74 69 6f 6e 20 69 |also a s|ection i|
|00002f80| 6e 20 54 48 49 4e 4b 20 | 52 65 66 65 72 65 6e 63 |n THINK |Referenc|
|00002f90| 65 20 77 68 69 63 68 20 | 6c 69 73 74 73 20 61 6c |e which |lists al|
|00002fa0| 6c 20 74 68 65 20 63 61 | 6c 6c 73 20 66 72 6f 6d |l the ca|lls from|
|00002fb0| 20 49 6e 73 69 64 65 20 | 4d 61 63 69 6e 74 6f 73 | Inside |Macintos|
|00002fc0| 68 20 49 2d 56 20 28 65 | 78 63 65 70 74 20 6f 66 |h I-V (e|xcept of|
|00002fd0| 20 63 6f 75 72 73 65 20 | 74 68 65 20 41 70 70 6c | course |the Appl|
|00002fe0| 65 54 61 6c 6b 20 61 6e | 64 20 53 6f 75 6e 64 20 |eTalk an|d Sound |
|00002ff0| 4d 61 6e 61 67 65 72 73 | 29 20 61 6e 64 20 77 68 |Managers|) and wh|
|00003000| 65 74 68 65 72 20 74 68 | 65 79 20 6d 6f 76 65 20 |ether th|ey move |
|00003010| 6d 65 6d 6f 72 79 20 6f | 72 20 6e 6f 74 2e 0d 41 |memory o|r not..A|
|00003020| 20 63 61 73 65 20 77 68 | 69 63 68 20 63 61 6e 20 | case wh|ich can |
|00003030| 62 65 20 63 6f 6e 66 75 | 73 69 6e 67 20 69 73 20 |be confu|sing is |
|00003040| 61 20 68 61 6e 64 6c 65 | 20 74 6f 20 61 20 73 74 |a handle| to a st|
|00003050| 72 75 63 74 75 72 65 20 | 77 68 69 63 68 20 63 6f |ructure |which co|
|00003060| 6e 74 61 69 6e 73 20 70 | 6f 69 6e 74 65 72 73 2e |ntains p|ointers.|
|00003070| 20 49 66 20 79 6f 75 20 | 6e 65 65 64 20 74 6f 20 | If you |need to |
|00003080| 70 61 73 73 20 6f 6e 65 | 20 6f 66 20 74 68 65 20 |pass one| of the |
|00003090| 70 6f 69 6e 74 65 72 73 | 20 74 6f 20 61 20 74 6f |pointers| to a to|
|000030a0| 6f 6c 62 6f 78 20 63 61 | 6c 6c 20 77 68 69 63 68 |olbox ca|ll which|
|000030b0| 20 6d 61 79 20 6d 6f 76 | 65 20 6d 65 6d 6f 72 79 | may mov|e memory|
|000030c0| 2c 20 64 6f 20 79 6f 75 | 20 6e 65 65 64 20 74 6f |, do you| need to|
|000030d0| 20 6c 6f 63 6b 20 74 68 | 65 20 68 61 6e 64 6c 65 | lock th|e handle|
|000030e0| 3f 20 54 68 65 20 61 6e | 73 77 65 72 20 69 73 20 |? The an|swer is |
|000030f0| 6e 6f 2c 20 69 66 20 79 | 6f 75 20 61 72 65 20 70 |no, if y|ou are p|
|00003100| 61 73 73 69 6e 67 20 74 | 68 65 20 70 6f 69 6e 74 |assing t|he point|
|00003110| 65 72 20 62 79 20 76 61 | 6c 75 65 20 28 69 6e 20 |er by va|lue (in |
|00003120| 50 61 73 63 61 6c 29 20 | 6f 72 20 6f 6e 20 74 68 |Pascal) |or on th|
|00003130| 65 20 73 74 61 63 6b 20 | 28 69 6e 20 43 20 70 61 |e stack |(in C pa|
|00003140| 72 6c 61 6e 63 65 29 2e | 20 53 69 6e 63 65 20 77 |rlance).| Since w|
|00003150| 68 61 74 20 69 73 20 62 | 65 69 6e 67 20 75 73 65 |hat is b|eing use|
|00003160| 64 20 69 73 20 61 63 74 | 75 61 6c 6c 79 20 61 20 |d is act|ually a |
|00003170| 72 65 61 6c 20 70 6f 69 | 6e 74 65 72 2c 20 6e 6f |real poi|nter, no|
|00003180| 20 70 72 6f 62 6c 65 6d | 20 6f 63 63 75 72 73 2e | problem| occurs.|
|00003190| 20 54 68 65 20 70 6f 69 | 6e 74 65 72 20 69 74 73 | The poi|nter its|
|000031a0| 65 6c 66 20 69 73 20 70 | 61 73 73 65 64 2e 20 49 |elf is p|assed. I|
|000031b0| 66 2c 20 68 6f 77 65 76 | 65 72 2c 20 79 6f 75 20 |f, howev|er, you |
|000031c0| 77 65 72 65 20 70 61 73 | 73 69 6e 67 20 74 68 65 |were pas|sing the|
|000031d0| 20 61 64 64 72 65 73 73 | 20 6f 66 20 74 68 65 20 | address| of the |
|000031e0| 70 6f 69 6e 74 65 72 20 | 28 61 20 76 61 72 20 70 |pointer |(a var p|
|000031f0| 61 72 61 6d 65 74 65 72 | 20 69 6e 20 50 61 73 63 |arameter| in Pasc|
|00003200| 61 6c 29 20 62 65 63 61 | 75 73 65 20 69 74 20 6d |al) beca|use it m|
|00003210| 69 67 68 74 20 63 68 61 | 6e 67 65 20 28 73 61 79 |ight cha|nge (say|
|00003220| 20 79 6f 75 20 68 61 64 | 20 61 20 66 75 6e 63 74 | you had| a funct|
|00003230| 69 6f 6e 20 73 69 6d 69 | 6c 61 72 20 74 6f 20 48 |ion simi|lar to H|
|00003240| 61 6e 64 54 6f 48 61 6e | 64 20 62 75 74 20 77 72 |andToHan|d but wr|
|00003250| 69 74 74 65 6e 20 74 6f | 20 75 73 65 20 70 6f 69 |itten to| use poi|
|00003260| 6e 74 65 72 73 29 2c 20 | 74 68 65 6e 20 74 68 65 |nters), |then the|
|00003270| 20 68 61 6e 64 6c 65 20 | 77 6f 75 6c 64 20 6e 65 | handle |would ne|
|00003280| 6e 20 74 6f 20 6f 70 74 | 69 6d 69 7a 65 20 69 6e |n to opt|imize in|
|00003290| 74 65 6c 6c 69 67 65 6e | 74 6c 79 2e 20 43 6f 6e |telligen|tly. Con|
|000032a0| 63 65 6e 74 72 61 74 65 | 20 6f 6e 20 61 72 65 61 |centrate| on area|
|000032b0| 73 20 77 68 69 63 68 20 | 61 72 65 20 63 72 75 63 |s which |are cruc|
|000032c0| 69 61 6c 20 6f 72 20 68 | 61 76 65 20 68 69 67 68 |ial or h|ave high|
|000032d0| 20 75 73 65 72 20 76 69 | 73 69 62 69 6c 69 74 79 | user vi|sibility|
|000032e0| 20 66 69 72 73 74 2e 0d | 0d 4d 6f 73 74 20 64 65 | first..|.Most de|
|000032f0| 76 65 6c 6f 70 6d 65 6e | 74 20 65 6e 76 69 72 6f |velopmen|t enviro|
|00003300| 6e 6d 65 6e 74 73 20 68 | 61 76 65 20 61 20 70 72 |nments h|ave a pr|
|00003310| 6f 66 69 6c 65 72 20 73 | 75 70 70 6c 69 65 64 20 |ofiler s|upplied |
|00003320| 77 69 74 68 20 74 68 65 | 6d 2e 20 4d 50 57 20 68 |with the|m. MPW h|
|00003330| 61 73 20 61 20 74 6f 6f | 6c 20 63 61 6c 6c 65 64 |as a too|l called|
|00003340| 20 50 72 6f 66 66 2c 20 | 77 68 69 6c 65 20 62 6f | Proff, |while bo|
|00003350| 74 68 20 54 48 49 4e 4b | 20 43 20 61 6e 64 20 50 |th THINK| C and P|
|00003360| 61 73 63 61 6c 20 68 61 | 76 65 20 74 68 65 69 72 |ascal ha|ve their|
|00003370| 61 73 63 61 6c 20 68 61 | 76 65 20 74 68 65 69 72 |ascal ha|ve their|
|00003380| 75 70 79 69 6e 67 20 74 | 68 65 20 73 70 6f 74 20 |upying t|he spot |
|00003390| 77 68 69 63 68 20 69 73 | 20 61 62 6f 75 74 20 74 |which is| about t|
|000033a0| 6f 20 62 65 20 6f 76 65 | 72 77 72 69 74 74 65 6e |o be ove|rwritten|
|000033b0| 2e 0d 53 6f 20 77 68 61 | 74 20 64 6f 65 73 20 61 |..So wha|t does a|
|000033c0| 6c 6c 20 74 68 69 73 20 | 68 61 76 65 20 74 6f 20 |ll this |have to |
|000033d0| 64 6f 20 77 69 74 68 20 | 73 6f 75 72 63 65 20 63 |do with |source c|
|000033e0| 6f 64 65 20 6f 70 74 69 | 6d 69 7a 61 74 69 6f 6e |ode opti|mization|
|000033f0| 3f 20 43 61 6c 6c 69 6e | 67 20 48 4c 6f 63 6b 20 |? Callin|g HLock |
|00003400| 65 78 63 65 73 73 69 76 | 65 6c 79 20 63 61 6e 20 |excessiv|ely can |
|00003410| 62 65 20 65 78 70 65 6e | 73 69 76 65 2e 20 45 76 |be expen|sive. Ev|
|00003420| 65 6e 20 74 68 6f 75 67 | 68 20 74 68 65 20 69 6e |en thoug|h the in|
|00003430| 74 65 72 6e 61 6c 73 20 | 6f 66 20 74 68 65 20 74 |ternals |of the t|
|00003440| 72 61 70 20 61 72 65 20 | 76 65 72 79 20 73 68 6f |rap are |very sho|
|00003450| 72 74 2c 20 74 68 65 20 | 74 72 61 70 20 64 69 73 |rt, the |trap dis|
|00003460| 70 61 74 63 68 65 72 20 | 68 61 73 20 61 20 68 69 |patcher |has a hi|
|00003470| 67 68 20 6f 76 65 72 68 | 65 61 64 2e 20 28 52 65 |gh overh|ead. (Re|
|00003480| 6d 65 6d 62 65 72 20 74 | 68 65 20 66 69 72 73 74 |member t|he first|
|00003490| 20 72 75 6c 65 20 6f 66 | 20 74 68 75 6d 62 2c 20 | rule of| thumb, |
|000034a0| 64 69 73 63 75 73 73 65 | 64 20 70 72 65 76 69 6f |discusse|d previo|
|000034b0| 75 73 6c 79 2e 29 20 41 | 6e 64 20 61 66 74 65 72 |usly.) A|nd after|
|000034c0| 20 79 6f 75 20 61 72 65 | 20 64 6f 6e 65 20 64 65 | you are| done de|
|000034d0| 2d 72 65 66 65 72 65 6e | 63 69 6e 67 20 74 68 65 |-referen|cing the|
|000034e0| 20 68 61 6e 64 6c 65 20 | 28 69 66 20 79 6f 75 20 | handle |(if you |
|000034f0| 64 6f 6e d5 74 20 64 69 | 73 70 6f 73 65 20 6f 66 |don.t di|spose of|
|00003500| 20 69 74 29 20 69 74 20 | 6e 65 65 64 73 20 74 6f | it) it |needs to|
|00003510| 20 62 65 20 75 6e 6c 6f | 63 6b 65 64 2e 20 28 46 | be unlo|cked. (F|
|00003520| 61 69 6c 75 72 65 20 74 | 6f 20 75 6e 6c 6f 63 6b |ailure t|o unlock|
|00003530| 20 68 61 6e 64 6c 65 73 | 20 77 69 6c 6c 20 6c 65 | handles| will le|
|00003540| 61 64 20 74 6f 20 68 65 | 61 70 20 66 72 61 67 6d |ad to he|ap fragm|
|00003550| 65 6e 74 61 74 69 6f 6e | 20 61 6e 64 20 69 73 20 |entation| and is |
|00003560| 61 20 6c 65 61 64 69 6e | 67 20 63 61 75 73 65 20 |a leadin|g cause |
|00003570| 6f 66 20 74 6f 6f 74 68 | 20 64 65 63 61 79 2e 29 |of tooth| decay.)|
|00003580| 0d 41 20 63 6f 72 6f 6c | 6c 61 72 79 20 74 6f 20 |.A corol|lary to |
|00003590| 74 68 65 20 65 78 63 65 | 73 73 69 76 65 20 48 4c |the exce|ssive HL|
|000035a0| 6f 63 6b 2f 48 55 6e 6c | 6f 63 6b 20 70 72 6f 62 |ock/HUnl|ock prob|
|000035b0| 6c 65 6d 20 69 73 20 74 | 6f 20 6e 6f 74 20 6c 6f |lem is t|o not lo|
|000035c0| 63 6b 20 74 68 65 20 73 | 61 6d 65 20 68 61 6e 64 |ck the s|ame hand|
|000035d0| 6c 65 20 72 65 70 65 61 | 74 65 64 6c 79 20 69 6e |le repea|tedly in|
|000035e0| 20 61 20 73 69 6e 67 6c | 65 20 72 6f 75 74 69 6e | a singl|e routin|
|000035f0| 65 2e 20 49 66 20 79 6f | 75 20 6e 65 65 64 20 74 |e. If yo|u need t|
|00003600| 6f 20 6c 6f 63 6b 20 61 | 6e 64 20 75 6e 6c 6f 63 |o lock a|nd unloc|
|00003610| 6b 20 69 74 20 6d 75 6c | 74 69 70 6c 65 20 74 69 |k it mul|tiple ti|
|00003620| 6d 65 73 2c 20 61 73 6b | 20 79 6f 75 72 73 65 6c |mes, ask| yoursel|
|00003630| 66 20 77 68 79 2e 20 44 | 6f 65 73 20 69 74 20 6d |f why. D|oes it m|
|00003640| 61 6b 65 20 6d 6f 72 65 | 20 73 65 6e 73 65 20 74 |ake more| sense t|
|00003650| 6f 20 6a 75 73 74 20 6c | 6f 63 6b 20 69 74 20 6f |o just l|ock it o|
|00003660| 6e 63 65 20 61 74 20 74 | 68 65 20 62 65 67 69 6e |nce at t|he begin|
|00003670| 6e 69 6e 67 20 6f 66 20 | 74 68 65 20 72 6f 75 74 |ning of |the rout|
|00003680| 69 6e 65 20 61 6e 64 20 | 75 6e 6c 6f 63 6b 20 69 |ine and |unlock i|
|00003690| 74 20 62 65 66 6f 72 65 | 20 65 78 69 74 69 6e 67 |t before| exiting|
|000036a0| 3f 20 54 68 65 20 6f 6e | 6c 79 20 74 69 6d 65 20 |? The on|ly time |
|000036b0| 74 68 69 73 20 69 73 6e | d5 74 20 74 72 75 65 20 |this isn|.t true |
|000036c0| 69 73 20 77 68 65 6e 20 | 74 68 65 72 65 20 69 73 |is when |there is|
|000036d0| 20 61 20 66 61 69 72 20 | 61 6d 6f 75 6e 74 20 6f | a fair |amount o|
|000036e0| 66 20 6d 65 6d 6f 72 79 | 20 6d 6f 76 65 6d 65 6e |f memory| movemen|
|000036f0| 74 20 68 61 70 70 65 6e | 69 6e 67 20 69 6e 20 74 |t happen|ing in t|
|00003700| 68 65 20 72 6f 75 74 69 | 6e 65 20 77 68 65 72 65 |he routi|ne where|
|00003710| 20 74 68 65 20 6c 6f 63 | 6b 65 64 20 64 6f 77 6e | the loc|ked down|
|00003720| 20 68 61 6e 64 6c 65 20 | 63 6f 75 6c 64 20 66 72 | handle |could fr|
|00003730| 61 67 6d 65 6e 74 20 6d | 65 6d 6f 72 79 2e 0d 41 |agment m|emory..A|
|00003740| 6c 73 6f 20 72 65 6c 61 | 74 65 64 20 74 6f 20 63 |lso rela|ted to c|
|00003750| 61 6c 6c 69 6e 67 20 48 | 4c 6f 63 6b 20 61 72 65 |alling H|Lock are|
|00003760| 20 63 61 6c 6c 73 20 74 | 6f 20 48 47 65 74 53 74 | calls t|o HGetSt|
|00003770| 61 74 65 20 61 6e 64 20 | 48 53 65 74 53 74 61 74 |ate and |HSetStat|
|00003780| 65 2c 20 77 68 69 63 68 | 20 61 72 65 20 75 73 65 |e, which| are use|
|00003790| 64 20 74 6f 20 6d 61 6b | 65 20 73 75 72 65 20 74 |d to mak|e sure t|
|000037a0| 68 65 20 68 61 6e 64 6c | 65 20 69 73 6e d5 74 20 |he handl|e isn.t |
|000037b0| 75 6e 6c 6f 63 6b 65 64 | 20 75 6e 65 78 70 65 63 |unlocked| unexpec|
|000037c0| 74 65 64 6c 79 20 66 6f | 72 20 61 6e 6f 74 68 65 |tedly fo|r anothe|
|000037d0| 72 20 70 69 65 63 65 20 | 6f 66 20 63 6f 64 65 2e |r piece |of code.|
|000037e0| 20 49 66 20 74 68 65 20 | 66 6c 6f 77 20 6f 66 20 | If the |flow of |
|000037f0| 63 6f 64 65 20 69 73 20 | 61 6e 61 6c 79 7a 65 64 |code is |analyzed|
|00003800| 20 69 74 20 69 73 20 73 | 6f 6d 65 74 69 6d 65 73 | it is s|ometimes|
|00003810| 20 70 6f 73 73 69 62 6c | 65 20 74 6f 20 61 76 6f | possibl|e to avo|
|00003820| 69 64 20 74 68 65 73 65 | 20 65 78 74 72 61 20 63 |id these| extra c|
|00003830| 61 6c 6c 73 20 62 79 20 | 6b 6e 6f 77 69 6e 67 20 |alls by |knowing |
|00003840| 74 68 61 74 20 61 20 68 | 61 6e 64 6c 65 20 77 69 |that a h|andle wi|
|00003850| 6c 6c 20 6e 65 76 65 72 | 20 62 65 20 6c 6f 63 6b |ll never| be lock|
|00003860| 65 64 20 77 68 65 6e 20 | 61 20 72 6f 75 74 69 6e |ed when |a routin|
|00003870| 65 20 69 73 20 63 61 6c | 6c 65 64 20 77 68 69 63 |e is cal|led whic|
|00003880| 68 20 75 73 65 73 20 69 | 74 2c 20 6f 72 20 62 79 |h uses i|t, or by|
|00003890| 20 6b 6e 6f 77 69 6e 67 | 20 74 68 61 74 20 74 68 | knowing| that th|
|000038a0| 65 20 68 61 6e 64 6c 65 | 20 77 69 6c 6c 20 61 6c |e handle| will al|
|000038b0| 77 61 79 73 20 62 65 20 | 6c 6f 63 6b 65 64 2c 20 |ways be |locked, |
|000038c0| 74 68 65 72 65 62 79 20 | 61 76 6f 69 64 69 6e 67 |thereby |avoiding|
|000038d0| 20 74 68 65 20 6e 65 65 | 64 20 74 6f 20 67 65 74 | the nee|d to get|
|000038e0| 20 74 68 65 20 73 74 61 | 74 65 2c 20 6c 6f 63 6b | the sta|te, lock|
|000038f0| 20 69 74 2c 20 74 68 65 | 6e 20 72 65 73 65 74 20 | it, the|n reset |
|00003900| 74 68 65 20 73 74 61 74 | 65 20 77 68 65 6e 20 74 |the stat|e when t|
|00003910| 68 65 20 68 61 6e 64 6c | 65 20 75 73 61 67 65 20 |he handl|e usage |
|00003920| 69 73 20 64 6f 6e 65 2e | 20 28 49 6d 61 67 69 6e |is done.| (Imagin|
|00003930| 65 2c 20 61 76 6f 69 64 | 69 6e 67 20 74 68 65 20 |e, avoid|ing the |
|00003940| 74 72 61 70 20 64 69 73 | 70 61 74 63 68 65 72 20 |trap dis|patcher |
|00003950| 74 68 72 65 65 20 74 69 | 6d 65 73 20 6a 75 73 74 |three ti|mes just|
|00003960| 20 62 65 63 61 75 73 65 | 20 79 6f 75 20 6b 6e 6f | because| you kno|
|00003970| 77 20 74 68 65 20 73 74 | 61 74 65 20 6f 66 20 61 |w the st|ate of a|
|00003980| 64 72 61 77 62 61 63 6b | 20 74 6f 20 70 72 6f 66 |drawback| to prof|
|00003990| 69 6c 65 73 20 28 65 73 | 70 65 63 69 61 6c 6c 79 |iles (es|pecially|
|000039a0| 20 6f 6e 20 74 68 65 20 | 4d 61 63 69 6e 74 6f 73 | on the |Macintos|
|000039b0| 68 29 20 69 73 20 74 68 | 65 20 61 6d 6f 75 6e 74 |h) is th|e amount|
|000039c0| 20 6f 66 20 74 69 6d 65 | 20 73 70 65 6e 74 20 69 | of time| spent i|
|000039d0| 6e 20 74 68 65 20 6d 61 | 69 6e 20 65 76 65 6e 74 |n the ma|in event|
|000039e0| 20 6c 6f 6f 70 20 6f 66 | 20 61 20 70 72 6f 67 72 | loop of| a progr|
|000039f0| 61 6d 2e 20 55 6e 6c 65 | 73 73 20 73 70 65 63 69 |am. Unle|ss speci|
|00003a00| 61 6c 20 63 61 72 65 20 | 69 73 20 74 61 6b 65 6e |al care |is taken|
|00003a10| 20 74 6f 20 74 75 72 6e | 20 6f 66 66 20 70 72 6f | to turn| off pro|
|00003a20| 66 69 6c 69 6e 67 20 4f | 4e 4c 59 20 69 6e 20 74 |filing O|NLY in t|
|00003a30| 68 65 20 6d 61 69 6e 20 | 6c 6f 6f 70 2c 20 61 6c |he main |loop, al|
|00003a40| 6c 20 73 74 61 74 69 73 | 74 69 63 73 20 67 61 74 |l statis|tics gat|
|00003a50| 68 65 72 65 64 20 77 69 | 6c 6c 20 62 65 20 64 69 |hered wi|ll be di|
|00003a60| 73 74 6f 72 74 65 64 2c | 20 6f 66 74 65 6e 20 73 |storted,| often s|
|00003a70| 68 6f 77 69 6e 67 20 74 | 68 65 20 6d 61 69 6e 20 |howing t|he main |
|00003a80| 79 2e 20 54 68 69 73 20 | 63 61 6e 20 62 65 20 61 |y. This |can be a|
|00003a90| 20 70 6f 74 65 6e 74 69 | 61 6c 6c 79 20 65 78 70 | potenti|ally exp|
|00003aa0| 65 6e 73 69 76 65 20 6f | 70 65 72 61 74 69 6f 6e |ensive o|peration|
|00003ab0| 2c 20 69 66 20 6f 74 68 | 65 72 20 6d 65 6d 6f 72 |, if oth|er memor|
|00003ac0| 79 20 6e 65 65 64 73 20 | 74 6f 20 62 65 20 73 68 |y needs |to be sh|
|00003ad0| 75 66 66 6c 65 64 20 66 | 6f 72 20 74 68 65 20 6d |uffled f|or the m|
|00003ae0| 6f 76 65 2e 20 49 74 20 | 73 68 6f 75 6c 64 20 6f |ove. It |should o|
|00003af0| 6e 6c 79 20 62 65 20 75 | 73 65 64 20 69 66 20 79 |nly be u|sed if y|
|00003b00| 6f 75 20 6b 6e 6f 77 20 | 74 68 65 20 62 6c 6f 63 |ou know |the bloc|
|00003b10| 6b 20 69 73 20 67 6f 69 | 6e 67 20 74 6f 20 6e 65 |k is goi|ng to ne|
|00003b20| 65 64 20 74 6f 20 62 65 | 20 6c 65 66 74 20 74 68 |ed to be| left th|
|00003b30| 65 72 65 20 66 6f 72 20 | 61 20 77 68 69 6c 65 20 |ere for |a while |
|00003b40| 6f 72 20 79 6f 75 20 6e | 65 65 64 20 74 6f 20 6c |or you n|eed to l|
|00003b50| 6f 63 6b 20 74 68 65 20 | 6d 65 6d 6f 72 79 20 61 |ock the |memory a|
|00003b60| 6e 64 20 79 6f 75 20 77 | 69 6c 6c 20 6e 65 65 64 |nd you w|ill need|
|00003b70| 20 74 6f 20 61 6c 6c 6f | 63 61 74 65 20 61 6e 6f | to allo|cate ano|
|00003b80| 74 68 65 72 20 6c 61 72 | 67 65 20 62 6c 6f 63 6b |ther lar|ge block|
|00003b90| 20 77 68 69 6c 65 20 69 | 74 20 69 73 20 6c 6f 63 | while i|t is loc|
|00003ba0| 6b 65 64 2e 0d 4f 6e 65 | 20 66 69 6e 61 6c 20 63 |ked..One| final c|
|00003bb0| 61 6c 6c 20 74 6f 20 61 | 76 6f 69 64 20 6f 76 65 |all to a|void ove|
|00003bc0| 72 75 73 69 6e 67 20 69 | 73 20 48 4e 6f 50 75 72 |rusing i|s HNoPur|
|00003bd0| 67 65 20 61 6e 64 20 48 | 50 75 72 67 65 2e 20 54 |ge and H|Purge. T|
|00003be0| 68 65 20 6f 6e 6c 79 20 | 74 69 6d 65 20 61 20 68 |he only |time a h|
|00003bf0| 61 6e 64 6c 65 20 77 69 | 6c 6c 20 62 65 20 6d 61 |andle wi|ll be ma|
|00003c00| 72 6b 65 64 20 61 73 20 | 70 75 72 67 65 61 62 6c |rked as |purgeabl|
|00003c10| 65 20 69 73 20 69 66 20 | 79 6f 75 20 63 61 6c 6c |e is if |you call|
|00003c20| 20 48 50 75 72 67 65 20 | 6f 6e 20 74 68 65 20 68 | HPurge |on the h|
|00003c30| 61 6e 64 6c 65 20 61 66 | 74 65 72 20 79 6f 75 20 |andle af|ter you |
|00003c40| 63 72 65 61 74 65 20 69 | 74 20 77 69 74 68 20 4e |create i|t with N|
|00003c50| 65 77 48 61 6e 64 6c 65 | 2c 20 6f 72 20 69 74 20 |ewHandle|, or it |
|00003c60| 69 73 20 61 20 72 65 73 | 6f 75 72 63 65 20 68 61 |is a res|ource ha|
|00003c70| 6e 64 6c 65 20 77 68 69 | 63 68 20 68 61 73 20 74 |ndle whi|ch has t|
|00003c80| 20 76 61 72 69 61 62 6c | 65 20 72 65 66 65 72 65 | variabl|e refere|
|00003c90| 6e 63 65 73 20 6f 72 20 | 63 6f 6d 70 75 74 61 74 |nces or |computat|
|00003ca0| 69 6f 6e 73 20 77 68 69 | 63 68 20 61 72 65 20 69 |ions whi|ch are i|
|00003cb0| 6e 76 61 72 69 61 62 6c | 65 20 62 65 74 77 65 65 |nvariabl|e betwee|
|00003cc0| 6e 20 61 20 74 72 61 70 | 20 63 61 6c 6c 20 6f 72 |n a trap| call or|
|00003cd0| 20 64 69 72 65 63 74 20 | 76 61 72 69 61 62 6c 65 | direct |variable|
|00003ce0| 20 73 65 74 74 69 6e 67 | 2e 29 0d 2b 09 41 76 6f | setting|.).+.Avo|
|00003cf0| 69 64 20 63 61 6c 6c 69 | 6e 67 20 61 6e 79 20 74 |id calli|ng any t|
|00003d00| 72 61 70 20 77 68 69 63 | 68 20 6f 6e 6c 79 20 73 |rap whic|h only s|
|00003d10| 65 74 73 20 73 69 6d 70 | 6c 65 20 73 74 72 75 63 |ets simp|le struc|
|00003d20| 74 75 72 65 20 76 61 6c | 75 65 73 20 66 72 6f 6d |ture val|ues from|
|00003d30| 20 74 68 65 20 70 61 72 | 61 6d 65 74 65 72 73 20 | the par|ameters |
|00003d40| 70 61 73 73 65 64 20 69 | 6e 74 6f 20 69 74 2e 0d |passed i|nto it..|
|00003d50| 0d 46 69 72 73 74 20 6f | 66 66 2c 20 61 20 74 72 |.First o|ff, a tr|
|00003d60| 69 76 69 61 6c 20 6f 70 | 74 69 6d 69 7a 61 74 69 |ivial op|timizati|
|00003d70| 6f 6e 20 77 68 69 63 68 | 20 64 6f 65 73 20 20 20 |on which| does |
|00003d80| 63 6f 64 65 20 66 6c 6f | 77 20 61 6e 64 20 61 72 |code flo|w and ar|
|00003d90| 72 61 6e 67 65 20 63 6f | 64 65 20 74 6f 20 61 76 |range co|de to av|
|00003da0| 6f 69 64 20 68 61 76 69 | 6e 67 20 74 6f 20 73 61 |oid havi|ng to sa|
|00003db0| 76 65 20 61 6e 64 20 72 | 65 73 74 6f 72 65 20 68 |ve and r|estore h|
|00003dc0| 61 6e 64 6c 65 20 73 74 | 61 74 65 73 2e 0d 2b 09 |andle st|ates..+.|
|00003dd0| 55 73 65 20 4d 6f 76 65 | 48 48 69 20 6f 6e 6c 79 |Use Move|HHi only|
|00003de0| 20 77 68 65 6e 20 79 6f | 75 72 20 61 72 65 20 67 | when yo|ur are g|
|00003df0| 6f 69 6e 67 20 74 6f 20 | 68 61 76 65 20 61 20 62 |oing to |have a b|
|00003e00| 6c 6f 63 6b 20 6c 6f 63 | 6b 65 64 20 66 6f 72 20 |lock loc|ked for |
|00003e10| 61 6e 20 65 78 74 65 6e | 64 65 64 20 70 65 72 69 |an exten|ded peri|
|00003e20| 6f 64 20 6f 66 20 74 69 | 6d 65 20 6f 72 20 79 6f |od of ti|me or yo|
|00003e30| 75 20 6e 65 65 64 20 74 | 6f 20 61 6c 6c 6f 63 61 |u need t|o alloca|
|00003e40| 74 65 20 61 20 6c 61 72 | 67 65 20 62 6c 6f 63 6b |te a lar|ge block|
|00003e50| 20 6f 66 20 6d 65 6d 6f | 72 79 20 61 6e 64 20 6e | of memo|ry and n|
|00003e60| 65 65 64 20 74 68 65 20 | 68 61 6e 64 6c 65 20 6c |eed the |handle l|
|00003e70| 6f 63 6b 65 64 2e 0d 2b | 09 44 6f 6e d5 74 20 63 |ocked..+|.Don.t c|
|00003e80| 20 69 74 20 63 61 6e 20 | 61 64 64 20 75 70 2e 0d | it can |add up..|
|00003e90| 41 6c 73 6f 2c 20 69 66 | 20 79 6f 75 20 70 61 73 |Also, if| you pas|
|00003ea0| 73 20 63 6f 6e 73 74 61 | 6e 74 73 20 74 6f 20 61 |s consta|nts to a|
|00003eb0| 20 73 65 74 20 6f 66 20 | 73 6d 61 6c 6c 20 70 61 | set of |small pa|
|00003ec0| 72 61 6d 65 74 65 72 73 | 20 28 73 75 63 68 20 61 |rameters| (such a|
|00003ed0| 73 20 74 77 6f 20 73 68 | 6f 72 74 73 20 6f 72 20 |s two sh|orts or |
|00003ee0| 74 77 6f 20 42 6f 6f 6c | 65 61 6e 73 29 2c 20 73 |two Bool|eans), s|
|00003ef0| 6f 6d 65 20 63 6f 6d 70 | 69 6c 65 72 73 20 77 69 |ome comp|ilers wi|
|00003f00| 6c 6c 20 62 75 6e 64 6c | 65 20 6d 75 6c 74 69 70 |ll bundl|e multip|
|00003f10| 6c 65 20 70 61 72 61 6d | 65 74 65 72 73 20 69 6e |le param|eters in|
|00003f20| 74 6f 20 61 20 73 69 6e | 67 6c 65 20 6d 61 63 68 |to a sin|gle mach|
|00003f30| 69 6e 65 20 69 6e 73 74 | 72 75 63 74 69 6f 6e 2e |ine inst|ruction.|
|00003f40| 0d 2b 09 41 6c 6c 6f 63 | 61 74 65 20 73 74 6f 72 |.+.Alloc|ate stor|
|00003f50| 61 67 65 20 66 6f 72 20 | 76 61 72 69 61 62 6c 65 |age for |variable|
|00003f60| 73 20 74 69 67 68 74 6c | 79 20 74 6f 20 64 65 63 |s tightl|y to dec|
|00003f70| 72 65 61 73 65 20 65 78 | 65 63 75 74 69 6f 6e 6e |rease ex|ecutionn|
|00003f80| 20 52 41 4d 20 72 65 71 | 75 69 72 65 6d 65 6e 74 | RAM req|uirement|
|00003f90| 73 2e 0d 2b 09 44 65 66 | 69 6e 65 20 72 6f 75 74 |s..+.Def|ine rout|
|00003fa0| 69 6e 65 73 20 74 6f 20 | 74 61 6b 65 20 63 68 61 |ines to |take cha|
|00003fb0| 72 61 63 74 65 72 20 61 | 6e 64 20 42 6f 6f 6c 65 |racter a|nd Boole|
|00003fc0| 61 6e 20 70 61 72 61 6d | 65 74 65 72 73 20 69 6e |an param|eters in|
|00003fd0| 20 74 77 6f 20 6f 72 20 | 66 6f 75 72 20 62 79 74 | two or |four byt|
|00003fe0| 65 20 67 72 6f 75 70 69 | 6e 67 73 2e 0d 0d 4e 65 |e groupi|ngs...Ne|
|00003ff0| 76 65 72 20 6c 65 74 20 | 79 6f 75 72 20 70 72 6f |ver let |your pro|
|00004000| 67 72 61 6d 20 64 6f 20 | 6d 6f 72 65 20 77 6f 72 |gram do |more wor|
|00004010| 6b 20 74 68 61 6e 20 69 | 74 20 68 61 73 20 74 6f |k than i|t has to|
|00004020| 20 64 6f 2e 20 43 68 65 | 63 6b 20 74 68 65 20 77 | do. Che|ck the w|
|00004030| 61 79 20 79 6f 75 72 20 | 63 6f 64 65 20 69 73 20 |ay your |code is |
|00004040| 73 74 72 75 63 74 75 72 | 65 64 2e 20 44 6f 65 73 |structur|ed. Does|
|00004050| 20 69 74 20 6d 61 6b 65 | 20 74 68 65 20 73 61 6d | it make| the sam|
|00004060| 65 20 73 65 72 69 65 73 | 20 6f 66 20 63 61 6c 6c |e series| of call|
|00004070| 73 20 61 74 20 74 77 6f | 20 64 69 66 66 65 72 72 |s at two| differr|
|00004080| 54 68 69 73 20 62 65 63 | 6f 6d 65 73 20 61 6e 20 |This bec|omes an |
|00004090| 69 73 73 75 65 20 69 66 | 20 79 6f 75 20 68 61 76 |issue if| you hav|
|000040a0| 65 20 61 20 68 61 6e 64 | 6c 65 20 74 6f 20 73 6f |e a hand|le to so|
|000040b0| 6d 65 20 68 65 61 76 69 | 6c 79 20 75 73 65 64 20 |me heavi|ly used |
|000040c0| 64 61 74 61 2e 20 44 65 | 70 65 6e 64 69 6e 67 20 |data. De|pending |
|000040d0| 6f 6e 20 74 68 65 20 63 | 6f 6d 70 69 6c 65 72 2c |on the c|ompiler,|
|000040e0| 20 79 6f 75 20 6d 61 79 | 20 62 65 20 75 73 69 6e | you may| be usin|
|000040f0| 67 20 74 77 6f 20 75 6e | 6e 65 63 65 73 73 61 72 |g two un|necessar|
|00004100| 79 20 69 6e 73 74 72 75 | 63 74 69 6f 6e 73 20 66 |y instru|ctions f|
|00004110| 6f 72 20 65 76 65 72 79 | 20 72 65 66 65 72 65 6e |or every| referen|
|00004120| 63 65 20 74 6f 20 74 68 | 65 20 64 61 74 61 2e 20 |ce to th|e data. |
|00004130| 49 66 20 79 6f 75 20 61 | 72 65 20 6d 61 6b 69 6e |If you a|re makin|
|00004140| 67 20 73 69 6d 70 6c 65 | 20 61 73 73 69 67 6e 6d |g simple| assignm|
|00004150| 65 6e 74 73 20 74 6f 20 | 66 69 65 6c 64 73 2c 20 |ents to |fields, |
|00004160| 74 68 69 73 20 63 61 6e | 20 64 6f 75 62 6c 65 20 |this can| double |
|00004170| 74 68 65 20 61 6d 6f 75 | 6e 74 20 6f 66 20 63 6f |the amou|nt of co|
|00004180| 64 65 20 65 78 65 63 75 | 74 65 64 2e 20 54 6f 20 |de execu|ted. To |
|00004190| 69 6d 70 72 6f 76 65 20 | 73 70 65 65 64 20 61 73 |improve |speed as|
|000041a0| 20 77 65 6c 6c 20 61 73 | 20 74 6f 20 64 65 63 72 | well as| to decr|
|000041b0| 65 61 73 65 20 63 6f 64 | 65 20 73 69 7a 65 2c 20 |ease cod|e size, |
|000041c0| 64 65 2d 72 65 66 65 72 | 65 6e 63 65 20 74 68 65 |de-refer|ence the|
|000041d0| 20 68 61 6e 64 6c 65 20 | 6f 6e 63 65 20 61 6e 64 | handle |once and|
|000041e0| 20 73 74 6f 72 65 20 74 | 68 65 20 72 65 73 75 6c | store t|he resul|
|000041f0| 74 69 6e 67 20 61 64 64 | 72 65 73 73 20 69 6e 20 |ting add|ress in |
|00004200| 61 20 70 6f 69 6e 74 65 | 72 2e 20 4e 6f 77 20 75 |a pointe|r. Now u|
|00004210| 73 65 20 74 68 65 20 70 | 6f 69 6e 74 65 72 20 74 |se the p|ointer t|
|00004220| 6f 20 61 63 63 65 73 73 | 20 74 68 65 20 64 61 74 |o access| the dat|
|00004230| 61 20 66 72 6f 6d 20 74 | 68 65 20 68 61 6e 64 6c |a from t|he handl|
|00004240| 65 20 72 65 70 65 61 74 | 65 64 6c 79 2e 20 0d 49 |e repeat|edly. .I|
|00004250| 66 20 79 6f 75 20 6b 6e | 6f 77 20 74 68 61 74 20 |f you kn|ow that |
|00004260| 79 6f 75 20 61 72 65 20 | 6e 6f 74 20 6d 6f 76 69 |you are |not movi|
|00004270| 6e 67 20 6d 65 6d 6f 72 | 79 20 66 6f 72 20 74 68 |ng memor|y for th|
|00004280| 65 20 65 6e 74 69 72 65 | 20 73 65 74 20 6f 66 20 |e entire| set of |
|00004290| 6f 70 65 72 61 74 69 6f | 6e 73 2c 20 79 6f 75 20 |operatio|ns, you |
|000042a0| 63 61 6e 20 61 76 6f 69 | 64 20 74 68 65 20 73 6c |can avoi|d the sl|
|000042b0| 6f 77 20 64 6f 77 6e 20 | 6f 66 20 6c 6f 63 6b 69 |ow down |of locki|
|000042c0| 6e 67 20 61 6e 64 20 75 | 6e 6c 6f 63 6b 69 6e 67 |ng and u|nlocking|
|000042d0| 20 74 68 65 20 68 61 6e | 64 6c 65 2c 20 73 61 76 | the han|dle, sav|
|000042e0| 69 6e 67 20 6d 6f 72 65 | 20 65 78 65 63 75 74 69 |ing more| executi|
|000042f0| 6f 6e 20 74 69 6d 65 20 | 61 6e 64 20 72 65 64 75 |on time |and redu|
|00004300| 63 69 6e 67 20 63 6f 64 | 65 20 73 69 7a 65 2e 0d |cing cod|e size..|
|00004310| 57 41 52 4e 49 4e 47 3a | 09 49 66 20 6d 65 6d 6f |WARNING:|.If memo|
|00004320| 72 79 20 6d 6f 76 65 73 | 20 62 65 63 61 75 73 65 |ry moves| because|
|00004330| 20 6f 66 20 61 6e 20 6f | 70 65 72 61 74 69 6f 6e | of an o|peration|
|00004340| 20 62 65 69 6e 67 20 70 | 65 72 66 6f 72 6d 65 64 | being p|erformed|
|00004350| 2c 20 74 68 65 20 70 6f | 69 6e 74 65 72 20 77 69 |, the po|inter wi|
|00004360| 6c 6c 20 62 65 63 6f 6d | 65 20 69 6e 76 61 6c 69 |ll becom|e invali|
|00004370| 64 2e 20 49 66 20 74 68 | 69 73 20 68 61 70 70 65 |d. If th|is happe|
|00004380| 68 65 20 52 65 73 50 75 | 72 67 65 64 20 62 69 74 |he ResPu|rged bit|
|00004390| 20 73 65 74 2e 20 54 68 | 65 73 65 20 61 72 65 20 | set. Th|ese are |
|000043a0| 74 68 65 20 6f 6e 6c 79 | 20 74 69 6d 65 73 20 77 |the only| times w|
|000043b0| 68 65 6e 20 79 6f 75 20 | 77 69 6c 6c 20 6e 65 65 |hen you |will nee|
|000043c0| 64 20 74 6f 20 77 6f 72 | 72 79 20 61 62 6f 75 74 |d to wor|ry about|
|000043d0| 20 74 68 65 20 63 6f 6e | 74 65 6e 74 73 20 6f 66 | the con|tents of|
|000043e0| 20 61 20 68 61 6e 64 6c | 65 20 67 65 74 74 69 6e | a handl|e gettin|
|000043f0| 67 20 70 75 72 67 65 64 | 2e 0d 2b 09 44 6f 6e d5 |g purged|..+.Don.|
|00004400| 74 20 6f 76 65 72 6c 6f | 63 6b 20 61 6e 64 20 75 |t overlo|ck and u|
|00004410| 6e 6c 6f 63 6b 20 68 61 | 6e 64 6c 65 73 2e 0d 2b |nlock ha|ndles..+|
|00004420| 09 41 6e 61 6c 79 7a 65 | 20 74 68 65 20 61 73 20 |.Analyze| the as |
|00004430| 70 75 72 67 65 61 62 6c | 65 20 61 66 74 65 72 20 |purgeabl|e after |
|00004440| 64 65 74 61 63 68 69 6e | 67 2e 5d 0d 2b 09 44 6f |detachin|g.].+.Do|
|00004450| 6e d5 74 20 6f 76 65 72 | 6c 6f 63 6b 20 61 6e 64 |n.t over|lock and|
|00004460| 20 75 6e 6c 6f 63 6b 20 | 68 61 6e 64 6c 65 73 2e | unlock |handles.|
|00004470| 0d 2b 09 41 6e 61 6c 79 | 7a 65 20 74 68 65 20 20 |.+.Analy|ze the |
|00004480| 20 77 68 61 74 20 6f 70 | 65 72 61 74 69 6f 6e 73 | what op|erations|
|00004490| 20 61 72 65 20 73 6c 75 | 67 67 69 73 68 2e 20 54 | are slu|ggish. T|
|000044a0| 68 65 6e 20 79 6f 75 20 | 63 61 6e 20 63 6f 6e 63 |hen you |can conc|
|000044b0| 65 6e 74 72 61 74 65 20 | 6f 6e 20 74 68 6f 73 65 |entrate |on those|
|000044c0| 20 61 72 65 61 73 20 66 | 6f 72 20 6d 61 6b 69 6e | areas f|or makin|
|000044d0| 67 20 73 70 65 65 64 20 | 69 6d 70 72 6f 76 65 6d |g speed |improvem|
|000044e0| 65 6e 74 73 2e 20 41 66 | 74 65 72 20 74 68 6f 73 |ents. Af|ter thos|
|000044f0| 65 20 61 72 65 61 73 20 | 68 61 76 65 20 62 65 20 |e areas |have be |
|00004500| 6f 70 74 69 6d 69 7a 65 | 64 2c 20 72 65 2d 69 74 |optimize|d, re-it|
|00004510| 65 72 61 74 65 20 74 68 | 65 20 73 70 65 65 64 20 |erate th|e speed |
|00004520| 74 65 73 74 69 6e 67 2e | 20 43 68 65 63 6b 20 74 |testing.| Check t|
|00004530| 6f 20 73 65 65 20 69 66 | 20 74 68 65 72 65 20 61 |o see if| there a|
|00004540| 72 65 20 6f 74 68 65 72 | 20 61 72 65 61 73 20 77 |re other| areas w|
|00004550| 68 69 63 68 20 63 61 6e | 20 62 65 20 69 6d 70 72 |hich can| be impr|
|00004560| 6f 76 65 64 2e 0d 41 20 | 4e 6f 74 65 20 41 62 6f |oved..A |Note Abo|
|00004570| 75 74 20 53 6f 75 72 63 | 65 20 43 43 63 65 20 43 |ut Sourc|e CCce C|
|00004580| 6f 62 6a 65 63 74 73 20 | 6f 6e 20 74 68 65 20 4d |objects |on the M|
|00004590| 61 63 69 6e 74 6f 73 68 | 20 61 72 65 20 68 61 6e |acintosh| are han|
|000045a0| 64 6c 65 20 62 61 73 65 | 64 2e 20 41 73 20 61 20 |dle base|d. As a |
|000045b0| 72 65 73 75 6c 74 2c 20 | 61 6c 6c 20 6f 66 20 74 |result, |all of t|
|000045c0| 68 65 20 69 6e 73 74 61 | 6e 63 65 20 76 61 72 69 |he insta|nce vari|
|000045d0| 61 62 6c 65 73 20 61 72 | 65 20 63 6f 6e 74 61 69 |ables ar|e contai|
|000045e0| 6e 65 64 20 77 69 74 68 | 69 6e 20 61 20 68 61 6e |ned with|in a han|
|000045f0| 64 6c 65 2e 20 52 65 66 | 65 72 65 6e 63 69 6e 67 |dle. Ref|erencing|
|00004600| 20 69 6e 73 74 61 6e 63 | 65 20 76 61 72 69 61 62 | instanc|e variab|
|00004610| 6c 65 73 20 62 65 63 6f | 6d 65 73 20 71 75 69 74 |les beco|mes quit|
|00004620| 65 20 73 6c 6f 77 20 28 | 61 73 20 77 65 6c 6c 20 |e slow (|as well |
|00004630| 70 72 6f 62 6c 65 6d 61 | 74 69 63 61 6c 20 73 69 |problema|tical si|
|00004640| 6e 63 65 20 74 68 65 20 | 68 61 6e 64 6c 65 20 63 |nce the |handle c|
|00004650| 6f 6e 74 61 69 6e 69 6e | 67 20 74 68 65 20 69 6e |ontainin|g the in|
|00004660| 73 74 61 6e 63 65 20 76 | 61 72 69 61 62 6c 65 20 |stance v|ariable |
|00004670| 63 61 6e 20 6d 6f 76 65 | 20 77 68 65 6e 20 6d 65 |can move| when me|
|00004680| 6e 73 20 79 6f 75 20 6d | 75 73 74 20 72 65 6c 6f |ns you m|ust relo|
|00004690| 61 64 20 74 68 65 20 70 | 6f 69 6e 74 65 72 20 66 |ad the p|ointer f|
|000046a0| 72 6f 6d 20 74 68 65 20 | 68 61 6e 64 6c 65 2e 0d |rom the |handle..|
|000046b0| 54 6f 20 66 75 72 74 68 | 65 72 20 69 6e 63 72 65 |To furth|er incre|
|000046c0| 61 73 65 20 63 6f 64 65 | 20 70 65 72 66 6f 72 6d |ase code| perform|
|000046d0| 61 6e 63 65 2c 20 67 72 | 6f 75 70 20 61 6c 6c 20 |ance, gr|oup all |
|000046e0| 6f 66 20 79 6f 75 72 20 | 6e 6f 6e 2d 76 6f 6c 61 |of your |non-vola|
|000046f0| 74 69 6c 65 20 6d 65 6d | 6f 72 79 20 61 73 73 69 |tile mem|ory assi|
|00004700| 67 6e 65 6e 74 73 20 6f | 72 20 75 73 61 67 65 73 |gnents o|r usages|
|00004710| 20 74 6f 67 65 74 68 65 | 72 2e 20 54 68 65 6e 20 | togethe|r. Then |
|00004720| 69 66 20 79 6f 75 20 64 | 6f 20 6e 65 65 64 20 74 |if you d|o need t|
|00004730| 6f 20 6c 6f 63 6b 20 74 | 68 65 20 68 61 6e 64 6c |o lock t|he handl|
|00004740| 65 2c 20 79 6f 75 20 63 | 61 6e 20 70 65 72 66 6f |e, you c|an perfo|
|00004750| 72 6d 20 61 6c 6c 20 6f | 66 20 74 68 65 20 6d 65 |rm all o|f the me|
|00004760| 6d 6f 72 79 20 76 6f 6c | 61 74 69 6c 65 20 66 75 |mory vol|atile fu|
|00004770| 6e 63 74 69 6f 6e 73 20 | 61 74 20 6f 6e 63 65 2e |nctions |at once.|
|00004780| 61 72 69 61 62 6c 65 20 | 74 6f 20 68 6f 6c 64 20 |ariable |to hold |
|00004790| 61 20 63 6f 70 79 20 6f | 66 20 74 68 65 20 76 61 |a copy o|f the va|
|000047a0| 72 69 61 62 6c 65 2e 20 | 49 74 20 77 69 6c 6c 20 |riable. |It will |
|000047b0| 74 61 6b 65 20 74 68 72 | 65 65 20 69 6e 73 74 72 |take thr|ee instr|
|000047c0| 75 63 74 69 6f 6e 73 20 | 74 6f 20 73 61 76 65 20 |uctions |to save |
|000047d0| 74 68 65 20 63 6f 70 79 | 20 69 6e 20 61 20 6c 6f |the copy| in a lo|
|000047e0| 63 61 6c 20 76 61 72 69 | 61 62 6c 65 2c 20 73 6f |cal vari|able, so|
|000047f0| 20 79 6f 75 20 6e 65 65 | 64 20 74 6f 20 62 61 6c | you nee|d to bal|
|00004800| 61 6e 63 65 20 74 68 61 | 74 20 74 69 6d 65 20 61 |ance tha|t time a|
|00004810| 67 61 69 6e 73 74 20 74 | 68 65 20 66 72 65 71 75 |gainst t|he frequ|
|00004820| 65 6e 63 79 20 6f 66 20 | 75 73 61 67 65 2e 0d 54 |ency of |usage..T|
|00004830| 68 65 72 65 20 73 65 76 | 65 72 61 6c 20 64 72 61 |here sev|eral dra|
|00004840| 77 62 61 63 6b 73 20 6f | 66 20 61 20 6c 6f 63 61 |wbacks o|f a loca|
|00004850| 6c 20 63 6f 70 79 20 6f | 66 20 74 68 65 20 76 61 |l copy o|f the va|
|00004860| 72 69 61 62 6c 65 20 77 | 68 69 63 68 20 6e 65 65 |riable w|hich nee|
|00004870| 64 20 74 6f 20 62 65 20 | 63 6f 6e 73 69 64 65 72 |d to be |consider|
|00004880| 65 64 20 62 65 66 6f 72 | 65 20 75 73 69 6e 67 20 |ed befor|e using |
|00004890| 6f 6e 65 2e 20 54 68 65 | 20 66 69 72 73 74 20 69 |one. The| first i|
|000048a0| 73 20 74 68 65 20 70 72 | 6f 62 6c 65 6d 20 6f 66 |s the pr|oblem of|
|000048b0| 20 63 68 61 6e 67 69 6e | 67 20 74 68 65 20 76 61 | changin|g the va|
|000048c0| 72 69 61 62 6c 65 2e 20 | 49 66 20 74 68 65 20 76 |riable. |If the v|
|000048d0| 61 6c 75 65 20 6f 66 20 | 74 68 65 20 76 61 72 69 |alue of |the vari|
|000048e0| 61 62 6c 65 20 64 6f 65 | 73 20 63 68 61 6e 67 65 |able doe|s change|
|000048f0| 2c 20 74 68 65 6e 20 74 | 68 65 20 6e 65 77 20 76 |, then t|he new v|
|00004900| 61 6c 75 65 20 77 69 6c | 6c 20 6e 65 65 64 20 74 |alue wil|l need t|
|00004910| 6f 20 62 65 20 73 61 76 | 65 64 20 62 61 63 6b 20 |o be sav|ed back |
|00004920| 69 6e 74 6f 20 74 68 65 | 20 61 63 74 75 61 6c 20 |into the| actual |
|00004930| 69 6e 73 74 61 6e 63 65 | 20 76 61 72 69 61 62 6c |instance| variabl|
|00004940| 65 2e 20 49 66 20 74 68 | 65 20 76 61 6c 75 65 20 |e. If th|e value |
|00004950| 69 73 20 63 68 61 6e 67 | 65 64 20 69 6e 20 74 68 |is chang|ed in th|
|00004960| 65 20 63 75 72 72 65 6e | 74 20 6d 65 74 68 6f 64 |e curren|t method|
|00004970| 20 6f 72 20 61 20 6d 65 | 74 68 6f 64 20 63 61 6c | or a me|thod cal|
|00004980| 6c 65 64 20 62 79 20 74 | 68 65 20 63 75 72 72 65 |led by t|he curre|
|00004990| 6e 74 20 6d 65 74 68 6f | 64 2c 20 74 68 65 6e 20 |nt metho|d, then |
|000049a0| 74 68 65 20 76 61 6c 75 | 65 20 77 69 6c 6c 20 6e |the valu|e will n|
|000049b0| 65 65 64 20 74 6f 20 62 | 65 20 72 65 6c 6f 61 64 |eed to b|e reload|
|000049c0| 65 64 20 61 6c 73 6f 2e | 20 54 68 69 73 20 6d 65 |ed also.| This me|
|000049d0| 61 6e 73 20 74 68 61 74 | 20 79 6f 75 20 6e 65 65 |ans that| you nee|
|000049e0| 64 20 74 6f 20 6b 6e 6f | 77 20 74 68 65 20 66 6c |d to kno|w the fl|
|000049f0| 6f 77 20 6f 66 20 74 68 | 65 20 63 6f 64 65 20 61 |ow of th|e code a|
|00004a00| 6e 64 20 77 68 65 74 68 | 65 72 20 79 6f 75 20 63 |nd wheth|er you c|
|00004a10| 61 6e 20 73 61 66 65 6c | 79 20 75 73 65 20 61 20 |an safel|y use a |
|00004a20| 6c 6f 63 61 6c 20 63 6f | 70 79 2e 0d 54 68 69 73 |local co|py..This|
|00004a30| 20 74 65 63 68 6e 69 71 | 75 65 20 61 6c 73 6f 20 | techniq|ue also |
|00004a40| 63 61 6e d5 74 20 62 65 | 20 75 73 65 64 20 74 6f |can.t be| used to|
|00004a50| 20 77 6f 72 6b 20 77 69 | 74 68 20 61 72 72 61 79 | work wi|th array|
|00004a60| 73 20 73 74 6f 72 65 64 | 20 69 6e 20 74 68 65 20 |s stored| in the |
|00004a70| 6f 62 6a 65 63 74 2e 20 | 54 68 65 20 64 61 74 61 |object. |The data|
|00004a80| 20 6d 75 63 68 20 77 6f | 72 6b 20 62 79 20 64 72 | much wo|rk by dr|
|00004a90| 61 77 69 6e 67 20 69 74 | 65 6d 73 20 6d 6f 72 65 |awing it|ems more|
|00004aa0| 20 74 68 61 6e 20 6f 6e | 63 65 2e 0d 2b 09 44 6f | than on|ce..+.Do|
|00004ab0| 6e d5 74 20 61 6c 6c 6f | 77 20 74 68 65 20 73 6f |n.t allo|w the so|
|00004ac0| 75 72 63 65 20 63 6f 64 | 65 20 74 6f 20 65 78 65 |urce cod|e to exe|
|00004ad0| 63 75 74 65 20 72 65 70 | 65 61 74 69 6e 67 20 63 |cute rep|eating c|
|00004ae0| 6f 64 65 2c 20 65 69 74 | 68 65 72 20 69 6e 20 61 |ode, eit|her in a|
|00004af0| 20 73 69 6e 67 6c 65 20 | 72 6f 75 74 69 6e 65 20 | single |routine |
|00004b00| 6f 72 20 74 68 72 6f 75 | 67 68 20 74 68 65 20 6c |or throu|gh the l|
|00004b10| 6f 67 69 63 20 66 6c 6f | 77 20 6f 66 20 74 68 65 |ogic flo|w of the|
|00004b20| 20 70 72 6f 67 72 61 6d | 2c 20 77 69 74 68 6f 75 | program|, withou|
|00004b30| 74 20 61 20 6e 65 63 65 | 73 73 61 72 79 20 72 65 |t a nece|ssary re|
|00004b40| 61 73 6f 6e 2e 0d 0d 43 | 68 65 63 6b 20 66 6f 72 |ason...C|heck for|
|00004b50| 20 6c 69 62 72 61 72 79 | 20 72 6f 75 74 69 6e 65 | library| routine|
|00004b60| 73 20 77 68 69 63 68 20 | 70 65 72 66 6f 72 6d 20 |s which |perform |
|00004b70| 66 75 6e 63 74 69 6f 6e | 73 20 79 6f 75 20 20 20 |function|s you |
|00004b80| 6d 65 6e 74 73 20 6f 72 | 20 75 73 61 67 65 73 20 |ments or| usages |
|00004b90| 74 6f 67 65 74 68 65 72 | 2e 20 54 68 65 6e 20 69 |together|. Then i|
|00004ba0| 66 20 79 6f 75 20 64 6f | 20 6e 65 65 64 20 74 6f |f you do| need to|
|00004bb0| 20 6c 6f 63 6b 20 74 68 | 65 20 68 61 6e 64 6c 65 | lock th|e handle|
|00004bc0| 2c 20 79 6f 75 20 63 61 | 6e 20 70 65 72 66 6f 72 |, you ca|n perfor|
|00004bd0| 6d 20 61 6c 6c 20 6f 66 | 20 74 68 65 20 6d 65 6d |m all of| the mem|
|00004be0| 6f 72 79 20 76 6f 6c 61 | 74 69 6c 65 20 66 75 6e |ory vola|tile fun|
|00004bf0| 63 74 69 6f 6e 73 20 61 | 74 20 6f 6e 63 65 2e 20 |ctions a|t once. |
|00004c00| 28 00 61 63 00 00 00 14 | 00 00 b4 08 00 0a 00 00 |(.ac....|........|
|00004c10| 00 00 00 00 00 00 64 20 | 00 00 00 14 00 00 b4 08 |......d |........|
|00004c20| 00 0a 01 e9 00 25 01 f9 | 01 06 20 64 00 00 00 14 |.....%..|.. d....|
|00004c30| 00 00 b4 f0 00 0a 01 f9 | 00 25 02 05 01 06 20 6f |........|.%.... o|
|00004c40| 00 00 00 14 00 00 b4 08 | 00 0a 00 00 00 00 00 00 |........|........|
|00004c50| 00 00 00 25 00 00 00 14 | 00 00 b4 08 00 0a 00 00 |...%....|........|
|00004c60| 00 00 00 00 00 00 74 68 | 00 00 00 14 00 00 b4 08 |......th|........|
|00004c70| 00 0a 00 00 00 00 00 00 | 00 00 72 61 00 00 00 14 |........|..ra....|
|00004c80| 72 61 6d 20 70 65 72 66 | 6f 72 6d 73 20 73 6f 6d |ram perf|orms som|
|00004c90| 65 20 6d 61 74 68 65 6d | 61 74 69 63 61 6c 20 66 |e mathem|atical f|
|00004ca0| 75 6e 63 74 69 6f 6e 73 | 2e 20 4d 75 6c 74 69 70 |unctions|. Multip|
|00004cb0| 6c 79 69 6e 67 20 61 6e | 64 20 64 69 76 69 64 69 |lying an|d dividi|
|00004cc0| 6e 67 20 76 61 6c 75 65 | 73 20 66 6f 72 20 64 72 |ng value|s for dr|
|00004cd0| 61 77 69 6e 67 20 6f 6e | 74 6f 20 74 68 65 20 73 |awing on|to the s|
|00004ce0| 63 72 65 65 6e 20 61 72 | 65 20 76 65 72 79 20 63 |creen ar|e very c|
|00004cf0| 6f 6d 6d 6f 6e 2e 20 42 | 75 74 2c 20 74 68 65 20 |ommon. B|ut, the |
|00004d00| 64 69 76 69 73 69 6f 6e | 20 69 6e 73 74 72 75 63 |division| instruc|
|00004d10| 74 69 6f 6e 20 69 73 20 | 74 68 65 20 73 69 6e 67 |tion is |the sing|
|00004d20| 6c 65 20 73 6c 6f 77 65 | 73 74 20 69 6e 73 74 72 |le slowe|st instr|
|00004d30| 75 63 74 69 6f 6e 20 6f | 6e 20 6d 6f 73 74 20 70 |uction o|n most p|
|00004d40| 72 6f 63 65 73 73 6f 72 | 73 2e 20 4f 6e 20 74 68 |rocessor|s. On th|
|00004d50| 65 20 36 38 30 30 30 2c | 20 61 20 73 69 67 6e 65 |e 68000,| a signe|
|00004d60| 64 20 64 69 76 69 73 69 | 6f 6e 20 63 61 6e 20 74 |d divisi|on can t|
|00004d70| 61 6b 65 20 31 35 38 20 | 70 72 6f 63 65 73 73 6f |ake 158 |processo|
|00004d80| 72 20 63 79 63 6c 65 73 | 2e 20 41 6c 74 68 6f 75 |r cycles|. Althou|
|00004d90| 67 68 20 74 68 61 74 20 | 6d 61 79 20 6e 6f 74 20 |gh that |may not |
|00004da0| 73 65 65 6d 20 6c 69 6b | 65 20 61 20 6c 6f 74 20 |seem lik|e a lot |
|00004db0| 6f 66 20 74 69 6d 65 20 | 66 6f 72 20 61 6e 20 69 |of time |for an i|
|00004dc0| 6e 73 74 72 75 63 74 69 | 6f 6e 20 28 63 6f 6d 70 |nstructi|on (comp|
|00004dd0| 61 72 65 64 20 74 6f 20 | 74 68 65 20 6e 75 6d 62 |ared to |the numb|
|00004de0| 65 72 20 6f 66 20 70 72 | 6f 63 65 73 73 6f 72 20 |er of pr|ocessor |
|00004df0| 63 79 63 6c 65 73 20 65 | 76 65 72 79 20 73 65 63 |cycles e|very sec|
|00004e00| 6f 6e 64 29 20 74 68 65 | 20 63 75 6d 75 6c 61 74 |ond) the| cumulat|
|00004e10| 69 76 65 20 65 66 66 65 | 63 74 20 63 61 6e 20 62 |ive effe|ct can b|
|00004e20| 65 20 6d 65 61 73 75 72 | 65 64 2e 20 43 6f 6e 73 |e measur|ed. Cons|
|00004e30| 69 64 65 72 20 20 61 20 | 6c 6f 6f 70 20 77 68 69 |ider a |loop whi|
|00004e40| 63 68 20 67 6f 65 73 20 | 66 72 6f 6d 20 31 20 74 |ch goes |from 1 t|
|00004e50| 6f 20 31 30 30 2e 20 49 | 6e 73 69 64 65 20 74 68 |o 100. I|nside th|
|00004e60| 61 74 20 6c 6f 6f 70 2c | 20 74 77 6f 20 64 69 76 |at loop,| two div|
|00004e70| 69 73 69 6f 6e 73 20 74 | 61 6b 65 20 70 6c 61 63 |isions t|ake plac|
|00004e80| 65 2e 20 54 68 69 73 20 | 63 6f 6d 65 73 20 74 6f |e. This |comes to|
|00004e90| 20 61 20 70 6f 74 65 6e | 74 69 61 6c 20 74 69 6d | a poten|tial tim|
|00004ea0| 65 20 6f 66 20 33 31 36 | 30 30 20 70 72 6f 63 65 |e of 316|00 proce|
|00004eb0| 73 73 6f 72 20 63 79 63 | 6c 65 73 20 6f 72 20 61 |ssor cyc|les or a|
|00004ec0| 62 6f 75 74 20 31 2f 32 | 35 30 74 68 20 6f 66 20 |bout 1/2|50th of |
|00004ed0| 61 20 73 65 63 6f 6e 64 | 20 6f 6e 20 61 20 43 6c |a second| on a Cl|
|00004ee0| 61 73 73 69 63 2e 20 57 | 68 69 6c 65 20 74 68 69 |assic. W|hile thi|
|00004ef0| 73 20 64 6f 65 73 20 6e | 6f 74 20 73 65 65 6d 20 |s does n|ot seem |
|00004f00| 6c 69 6b 65 20 61 20 6c | 6f 6e 67 20 74 69 6d 65 |like a l|ong time|
|00004f10| 2c 20 63 6f 6e 73 69 64 | 65 72 20 74 68 61 74 20 |, consid|er that |
|00004f20| 69 74 20 68 61 70 70 65 | 6e 73 20 65 76 65 72 79 |it happe|ns every|
|00004f30| 20 74 69 6d 65 20 74 68 | 72 6f 75 67 68 20 74 68 | time th|rough th|
|00004f40| 69 73 20 6c 6f 6f 70 2e | 20 32 35 30 20 63 61 6c |is loop.| 250 cal|
|00004f50| 6c 73 20 74 6f 20 74 68 | 69 73 20 6f 6e 65 20 6c |ls to th|is one l|
|00004f60| 6f 6f 70 20 61 64 64 73 | 20 75 70 20 74 6f 20 61 |oop adds| up to a|
|00004f70| 20 6f 6e 65 20 73 65 63 | 6f 6e 64 20 64 65 6c 61 | one sec|ond dela|
|00004f80| 79 2e 20 0d 47 72 61 6e | 74 65 64 2c 20 6f 6e 65 |y. .Gran|ted, one|
|00004f90| 20 73 65 63 6f 6e 64 20 | 64 6f 65 73 20 6e 6f 74 | second |does not|
|00004fa0| 20 73 65 65 6d 20 74 6f | 20 62 65 20 61 20 76 65 | seem to| be a ve|
|00004fb0| 72 79 20 6c 6f 6e 67 20 | 74 69 6d 65 2c 20 62 75 |ry long |time, bu|
|00004fc0| 74 20 63 6f 6e 73 69 64 | 65 72 20 74 68 69 73 3a |t consid|er this:|
|00004fd0| 20 48 6f 77 20 6d 61 6e | 79 20 74 69 6d 65 73 20 | How man|y times |
|00004fe0| 69 73 20 74 68 65 72 65 | 20 61 20 70 6f 74 65 6e |is there| a poten|
|00004ff0| 74 69 61 6c 20 6f 6e 65 | 20 73 65 63 6f 6e 64 20 |tial one| second |
|00005000| 64 65 6c 61 79 20 69 6e | 73 69 64 65 20 79 6f 75 |delay in|side you|
|00005010| 72 20 63 6f 64 65 3f 20 | 53 69 78 74 79 20 73 75 |r code? |Sixty su|
|00005020| 63 68 20 64 65 6c 61 79 | 73 20 74 61 6b 65 73 20 |ch delay|s takes |
|00005030| 75 70 20 61 20 6d 69 6e | 75 74 65 20 6f 66 20 72 |up a min|ute of r|
|00005040| 65 61 6c 20 74 69 6d 65 | 2e 0d 4d 75 6c 74 69 70 |eal time|..Multip|
|00005050| 6c 69 63 61 74 69 6f 6e | 20 74 61 6b 65 73 20 37 |lication| takes 7|
|00005060| 30 20 70 72 6f 63 65 73 | 73 6f 72 20 63 79 63 6c |0 proces|sor cycl|
|00005070| 65 73 2c 20 6a 75 73 74 | 20 75 6e 64 65 72 20 68 |es, just| under h|
|00005080| 61 6c 66 20 74 68 65 20 | 74 69 6d 65 20 74 68 61 |alf the |time tha|
|00005090| 74 20 61 20 64 69 76 69 | 73 69 6f 6e 20 74 61 6b |t a divi|sion tak|
|000050a0| 65 73 2e 20 54 68 61 74 | 20 69 73 20 73 74 69 6c |es. That| is stil|
|000050b0| 6c 20 73 6c 6f 77 2e 20 | 48 6f 77 20 6f 66 74 65 |l slow. |How ofte|
|000050c0| 6e 20 64 6f 20 79 6f 75 | 20 64 6f 20 61 20 6d 75 |n do you| do a mu|
|000050d0| 6c 74 69 70 6c 69 63 61 | 74 69 6f 6e 20 69 6e 20 |ltiplica|tion in |
|000050e0| 79 6f 75 72 20 73 6f 75 | 72 63 65 20 63 6f 64 65 |your sou|rce code|
|000050f0| 3f 0d 42 6f 74 68 20 6d | 75 6c 74 69 70 6c 69 63 |?.Both m|ultiplic|
|00005100| 61 74 69 6f 6e 20 61 6e | 64 20 64 69 76 69 73 69 |ation an|d divisi|
|00005110| 6f 6e 20 63 61 6e 20 62 | 65 20 64 6f 6e 65 2c 20 |on can b|e done, |
|00005120| 69 6e 20 63 65 72 74 61 | 69 6e 20 73 75 62 2d 63 |in certa|in sub-c|
|00005130| 61 73 65 73 2c 20 75 73 | 69 6e 67 20 62 69 74 20 |ases, us|ing bit |
|00005140| 73 68 69 66 74 69 6e 67 | 2e 20 49 66 20 74 68 65 |shifting|. If the|
|00005150| 20 6e 75 6d 62 65 72 20 | 62 65 69 6e 67 20 6d 75 | number |being mu|
|00005160| 6c 74 69 70 6c 69 65 64 | 20 6f 72 20 64 69 76 69 |ltiplied| or divi|
|00005170| 64 65 64 20 69 73 20 70 | 6f 73 69 74 69 76 65 2c |ded is p|ositive,|
|00005180| 52 65 6d 65 6d 62 65 72 | 20 6f 66 20 63 6f 75 72 |Remember| of cour|
|00005190| 73 65 20 74 6f 20 75 6e | 6c 6f 63 6b 20 74 68 65 |se to un|lock the|
|000051a0| 20 68 61 6e 64 6c 65 20 | 61 66 74 65 72 20 79 6f | handle |after yo|
|000051b0| 75 20 61 72 65 20 64 6f | 6e 65 20 69 66 20 61 70 |u are do|ne if ap|
|000051c0| 70 72 6f 70 72 69 61 74 | 65 2e 29 0d 2b 09 44 65 |propriat|e.).+.De|
|000051d0| 2d 72 65 66 65 72 65 6e | 63 65 20 61 20 68 61 6e |-referen|ce a han|
|000051e0| 64 6c 65 20 69 6e 74 6f | 20 61 20 70 6f 69 6e 74 |dle into| a point|
|000051f0| 65 72 20 66 6f 72 20 72 | 65 70 65 61 74 65 64 20 |er for r|epeated |
|00005200| 75 73 61 67 65 20 6f 66 | 20 74 68 65 20 68 61 6e |usage of| the han|
|00005210| 64 6c 65 20 63 6f 6e 74 | 65 6e 74 73 2c 20 74 6f |dle cont|ents, to|
|00005220| 20 69 6e 63 72 65 61 73 | 65 20 65 78 65 63 75 74 | increas|e execut|
|00005230| 69 6f 6e 20 73 70 65 65 | 64 20 61 6e 64 20 64 65 |ion spee|d and de|
|00005240| 63 72 65 61 73 65 20 63 | 6f 64 65 20 73 69 7a 65 |crease c|ode size|
|00005250| 2e 0d 0d 57 68 65 6e 20 | 75 73 69 6e 67 20 6f 62 |...When |using ob|
|00005260| 6a 65 63 74 2d 6f 72 69 | 65 6e 74 65 64 20 70 72 |ject-ori|ented pr|
|00005270| 6f 67 72 61 6d 6d 69 6e | 67 2c 20 6d 6f 73 74 20 |ogrammin|g, most |
|00005280| 6c 20 61 75 74 6f 6d 61 | 74 69 63 61 6c 6c 79 20 |l automa|tically |
|00005290| 75 73 65 20 62 69 74 20 | 73 68 69 66 74 69 6e 67 |use bit |shifting|
|000052a0| 20 66 6f 72 20 6d 75 6c | 74 69 70 6c 69 63 61 74 | for mul|tiplicat|
|000052b0| 69 6f 6e 20 28 54 48 49 | 4e 4b 20 43 2c 20 66 6f |ion (THI|NK C, fo|
|000052c0| 72 20 69 6e 73 74 61 6e | 63 65 20 77 69 6c 6c 29 |r instan|ce will)|
|000052d0| 2e 20 48 6f 77 65 76 65 | 72 2c 20 61 20 63 6f 6d |. Howeve|r, a com|
|000052e0| 70 69 6c 65 72 20 63 61 | 6e 20 6e 6f 74 20 73 61 |piler ca|n not sa|
|000052f0| 66 65 6c 79 20 62 69 74 | 20 73 68 69 66 74 20 66 |fely bit| shift f|
|00005300| 6f 72 20 61 20 64 69 76 | 69 73 69 6f 6e 2e 20 42 |or a div|ision. B|
|00005310| 69 74 20 73 68 69 66 74 | 69 6e 67 20 6f 6e 20 64 |it shift|ing on d|
|00005320| 69 76 69 73 69 6f 6e 73 | 20 77 69 6c 6c 20 6f 6e |ivisions| will on|
|00005330| 6c 79 20 77 6f 72 6b 20 | 63 6f 72 72 65 63 74 6c |ly work |correctl|
|00005340| 79 20 69 66 20 74 68 65 | 20 76 61 6c 75 65 20 62 |y if the| value b|
|00005350| 65 69 6e 67 20 64 69 76 | 69 64 65 64 20 69 73 20 |eing div|ided is |
|00005360| 70 6f 73 69 74 69 76 65 | 2e 20 59 6f 75 20 61 73 |positive|. You as|
|00005370| 20 61 20 70 72 6f 67 72 | 61 6d 6d 65 72 20 63 61 | a progr|ammer ca|
|00005380| 6e 20 6b 6e 6f 77 20 74 | 68 65 20 6c 65 67 61 6c |n know t|he legal|
|00005390| 20 72 61 6e 67 65 20 6f | 66 20 76 61 6c 75 65 73 | range o|f values|
|000053a0| 20 77 68 69 63 68 20 6d | 61 79 20 62 65 20 64 69 | which m|ay be di|
|000053b0| 76 69 64 65 64 20 61 6e | 64 20 75 73 65 20 62 69 |vided an|d use bi|
|000053c0| 74 20 73 68 69 66 74 69 | 6e 67 20 74 6f 20 79 6f |t shifti|ng to yo|
|000053d0| 75 72 20 61 64 76 61 6e | 74 61 67 65 2e 0d 42 69 |ur advan|tage..Bi|
|000053e0| 74 20 73 68 69 66 74 69 | 6e 67 20 28 77 69 74 68 |t shifti|ng (with|
|000053f0| 20 43 20 63 6f 6d 70 69 | 6c 65 72 73 29 20 69 73 | C compi|lers) is|
|00005400| 20 64 6f 6e 65 20 75 73 | 69 6e 67 20 74 68 65 20 | done us|ing the |
|00005410| 4c 53 4c 20 28 4c 6f 67 | 69 63 61 6c 20 53 68 69 |LSL (Log|ical Shi|
|00005420| 66 74 20 4c 65 66 74 29 | 20 61 6e 64 20 4c 53 52 |ft Left)| and LSR|
|00005430| 20 28 4c 6f 67 69 63 61 | 6c 20 53 68 69 66 74 20 | (Logica|l Shift |
|00005440| 52 69 67 68 74 29 20 69 | 6e 73 74 72 75 63 74 69 |Right) i|nstructi|
|00005450| 6f 6e 73 2e 20 54 68 65 | 73 65 20 69 6e 73 74 72 |ons. The|se instr|
|00005460| 75 63 74 69 6f 6e 73 20 | 64 6f 20 6e 6f 74 20 73 |uctions |do not s|
|00005470| 69 67 6e 20 65 78 74 65 | 6e 64 20 74 68 65 20 6e |ign exte|nd the n|
|00005480| 61 6c 6c 20 48 4e 6f 50 | 75 72 67 65 20 6f 72 20 |all HNoP|urge or |
|00005490| 48 50 75 72 67 65 20 6e | 65 65 64 6c 65 73 73 6c |HPurge n|eedlessl|
|000054a0| 79 2e 0d 0d 52 65 6d 65 | 6d 62 65 72 2c 20 69 66 |y...Reme|mber, if|
|000054b0| 20 79 6f 75 20 61 72 65 | 20 75 73 69 6e 67 20 70 | you are| using p|
|000054c0| 75 72 67 65 61 62 6c 65 | 20 68 61 6e 64 6c 65 73 |urgeable| handles|
|000054d0| 20 6f 72 20 72 65 73 6f | 75 72 63 65 73 2c 20 79 | or reso|urces, y|
|000054e0| 6f 75 20 77 69 6c 6c 20 | 6e 65 65 64 20 74 6f 20 |ou will |need to |
|000054f0| 63 68 65 63 6b 20 74 6f | 20 6d 61 6b 65 20 73 75 |check to| make su|
|00005500| 72 65 20 74 68 61 74 20 | 74 68 65 79 20 61 72 65 |re that |they are|
|00005510| 20 6c 6f 61 64 65 64 20 | 62 65 66 6f 72 65 20 74 | loaded |before t|
|00005520| 68 65 79 20 61 72 65 20 | 75 73 65 64 20 28 61 66 |hey are |used (af|
|00005530| 74 65 72 20 65 61 63 68 | 20 6d 65 6d 6f 72 79 20 |ter each| memory |
|00005540| 6d 6f 76 69 6e 67 20 6f | 70 65 72 61 74 69 6f 6e |moving o|peration|
|00005550| 29 2e 20 54 68 69 73 20 | 77 69 6c 6c 20 6f 62 76 |). This |will obv|
|00005560| 69 6f 75 73 6c 79 20 63 | 61 75 73 65 20 79 6f 75 |iously c|ause you|
|00005570| 72 20 63 6f 64 65 20 74 | 6f 20 65 78 65 63 75 75 |r code t|o execuu|
|00005580| 0d 43 6f 6d 6d 6f 6e 20 | 53 75 62 65 78 70 72 65 |.Common |Subexpre|
|00005590| 73 73 69 6f 6e 20 45 6c | 69 6d 69 6e 61 74 69 6f |ssion El|iminatio|
|000055a0| 6e 0d 43 6f 6d 6d 6f 6e | 20 53 75 62 65 78 70 72 |n.Common| Subexpr|
|000055b0| 65 73 73 69 6f 6e 73 20 | 61 72 65 20 70 69 65 63 |essions |are piec|
|000055c0| 65 73 20 6f 66 20 63 6f | 64 65 20 77 68 69 63 68 |es of co|de which|
|000055d0| 20 61 20 63 6f 6d 70 69 | 6c 65 72 20 64 65 74 65 | a compi|ler dete|
|000055e0| 72 6d 69 6e 65 73 20 70 | 65 72 66 6f 72 6d 20 74 |rmines p|erform t|
|000055f0| 68 65 20 73 61 6d 65 20 | 61 63 74 69 6f 6e 20 6d |he same |action m|
|00005600| 75 6c 74 69 70 6c 65 20 | 74 69 6d 65 73 2e 20 49 |ultiple |times. I|
|00005610| 74 20 69 73 20 73 6d 61 | 6c 6c 65 72 20 74 68 61 |t is sma|ller tha|
|00005620| 6e 20 61 6e 20 65 6e 74 | 69 72 65 20 6c 69 6e 65 |n an ent|ire line|
|00005630| 20 6f 66 20 63 6f 64 65 | 2c 20 75 73 75 61 6c 6c | of code|, usuall|
|00005640| 79 20 6a 75 73 74 20 61 | 20 73 6d 61 6c 6c 20 70 |y just a| small p|
|00005650| 69 65 63 65 20 6f 66 20 | 61 20 6c 61 72 67 65 72 |iece of |a larger|
|00005660| 20 65 78 70 72 65 73 73 | 69 6f 6e 2e 20 54 68 65 | express|ion. The|
|00005670| 20 63 6f 6d 70 69 6c 65 | 72 20 77 69 6c 6c 20 61 | compile|r will a|
|00005680| 74 74 65 6d 70 74 20 74 | 6f 20 6f 70 74 69 6d 69 |ttempt t|o optimi|
|00005690| 7a 65 20 74 68 69 73 20 | 63 6f 64 65 20 74 6f 20 |ze this |code to |
|000056a0| 6f 6e 6c 79 20 65 78 65 | 63 75 74 65 20 69 74 20 |only exe|cute it |
|000056b0| 6f 6e 63 65 20 61 6e 64 | 20 73 74 6f 72 65 20 74 |once and| store t|
|000056c0| 68 65 20 72 65 73 75 6c | 74 20 73 6f 20 69 74 20 |he resul|t so it |
|000056d0| 63 61 6e 20 62 65 20 75 | 73 65 64 20 69 6e 20 70 |can be u|sed in p|
|000056e0| 6c 61 63 65 20 6f 66 20 | 66 75 74 75 72 65 20 6f |lace of |future o|
|000056f0| 63 63 75 72 72 65 6e 63 | 65 73 20 6f 66 20 74 68 |ccurrenc|es of th|
|00005700| 65 20 73 75 62 65 78 70 | 72 65 73 73 69 6f 6e 2e |e subexp|ression.|
|00005710| 20 54 68 69 73 20 61 62 | 69 6c 69 74 79 20 69 73 | This ab|ility is|
|00005720| 20 67 65 6e 65 72 61 6c | 6c 79 20 6c 69 6d 69 74 | general|ly limit|
|00005730| 65 64 20 69 6e 20 69 74 | 73 20 73 63 6f 70 65 2e |ed in it|s scope.|
|00005740| 0d 41 20 68 75 6d 61 6e | 20 68 61 73 20 61 20 62 |.A human| has a b|
|00005750| 65 74 74 65 72 20 63 68 | 61 6e 63 65 20 6f 66 20 |etter ch|ance of |
|00005760| 66 69 6e 64 69 6e 67 20 | 63 6f 6d 6d 6f 6e 20 63 |finding |common c|
|00005770| 6f 64 65 20 74 68 61 6e | 20 61 20 63 6f 6d 70 69 |ode than| a compi|
|00005780| 6c 65 72 2e 20 41 20 70 | 65 72 73 6f 6e 20 63 61 |ler. A p|erson ca|
|00005790| 6e 20 6b 6e 6f 77 20 74 | 68 65 20 69 6e 74 65 6e |n know t|he inten|
|000057a0| 74 20 6f 66 20 74 68 65 | 20 63 6f 64 65 20 61 6e |t of the| code an|
|000057b0| 64 20 77 68 65 6e 20 6d | 75 6c 74 69 70 6c 65 20 |d when m|ultiple |
|000057c0| 65 78 70 72 65 73 73 69 | 6f 6e 73 20 63 61 6e 20 |expressi|ons can |
|000057d0| 62 65 20 73 69 6d 70 6c | 69 66 69 65 64 2e 20 49 |be simpl|ified. I|
|000057e0| 66 20 73 65 76 65 72 61 | 6c 20 6c 69 6e 65 73 20 |f severa|l lines |
|000057f0| 6f 66 20 63 6f 64 65 20 | 70 65 72 66 6f 72 6d 20 |of code |perform |
|00005800| 73 69 6d 69 6c 61 72 20 | 66 75 6e 63 74 69 6f 6e |similar |function|
|00005810| 73 2c 20 61 20 63 6f 6d | 6d 6f 6e 20 65 78 70 72 |s, a com|mon expr|
|00005820| 65 73 73 69 6f 6e 20 6d | 61 79 20 62 65 20 64 65 |ession m|ay be de|
|00005830| 72 69 76 65 64 20 77 69 | 74 68 20 61 6e 20 61 64 |rived wi|th an ad|
|00005840| 6a 75 73 74 6d 65 6e 74 | 20 6d 61 64 65 20 66 6f |justment| made fo|
|00005850| 72 20 65 61 63 68 20 75 | 73 61 67 65 2e 20 49 66 |r each u|sage. If|
|00005860| 20 74 68 65 20 73 75 62 | 65 78 70 72 65 73 73 69 | the sub|expressi|
|00005870| 6f 6e 20 69 73 20 6c 61 | 72 67 65 20 6f 72 20 63 |on is la|rge or c|
|00005880| 6f 6d 70 6c 65 78 20 65 | 6e 6f 75 67 68 2c 20 61 |omplex e|nough, a|
|00005890| 20 73 61 76 69 6e 67 73 | 20 63 61 6e 20 62 65 20 | savings| can be |
|000058a0| 68 61 64 2e 20 54 68 69 | 73 20 63 61 6e 20 62 65 |had. Thi|s can be|
|000058b0| 20 64 6f 6e 65 20 62 79 | 20 68 61 6e 64 2c 20 75 | done by| hand, u|
|000058c0| 73 69 6e 67 20 74 65 6d | 70 6f 72 61 72 79 20 6c |sing tem|porary l|
|000058d0| 6f 63 61 6c 20 76 61 72 | 69 61 62 6c 65 73 20 61 |ocal var|iables a|
|000058e0| 73 20 77 65 6c 6c 20 61 | 73 20 6c 65 74 74 69 6e |s well a|s lettin|
|000058f0| 67 20 74 68 65 20 63 6f | 6d 70 69 6c 65 72 20 61 |g the co|mpiler a|
|00005900| 74 74 65 6d 70 74 20 74 | 6f 20 66 69 6e 64 20 74 |ttempt t|o find t|
|00005910| 68 65 20 72 69 67 68 74 | 20 73 75 62 65 78 70 72 |he right| subexpr|
|00005920| 65 73 73 69 6f 6e 73 2e | 0d 41 20 63 6f 6d 70 69 |essions.|.A compi|
|00005930| 6c 65 72 20 64 6f 65 73 | 20 68 61 76 65 20 61 6e |ler does| have an|
|00005940| 20 61 64 76 61 6e 74 61 | 67 65 20 6f 76 65 72 20 | advanta|ge over |
|00005950| 61 20 68 75 6d 61 6e 20 | 69 6e 20 64 65 63 69 64 |a human |in decid|
|00005960| 69 6e 67 20 68 6f 77 20 | 74 6f 20 6f 70 74 69 6d |ing how |to optim|
|00005970| 69 7a 65 20 62 65 63 61 | 75 73 65 20 69 74 20 63 |ize beca|use it c|
|00005980| 61 6e 20 64 65 74 65 72 | 6d 69 6e 65 20 68 6f 77 |an deter|mine how|
|00005990| 20 72 65 67 69 73 74 65 | 72 73 20 61 72 65 20 75 | registe|rs are u|
|000059a0| 73 65 64 20 66 6f 72 20 | 74 68 65 20 6f 62 6a 65 |sed for |the obje|
|000059b0| 63 74 20 63 6f 64 65 2e | 20 46 6f 72 20 69 6e 73 |ct code.| For ins|
|000059c0| 74 61 6e 63 65 2c 20 61 | 20 68 65 61 76 69 6c 79 |tance, a| heavily|
|000059d0| 20 75 73 65 64 20 76 61 | 72 69 61 62 6c 65 20 77 | used va|riable w|
|000059e0| 68 69 63 68 20 68 61 73 | 20 61 20 63 6f 6e 73 74 |hich has| a const|
|000059f0| 61 6e 74 20 61 64 64 65 | 64 20 74 6f 20 69 74 20 |ant adde|d to it |
|00005a00| 69 6e 20 73 65 76 65 72 | 61 6c 20 70 6c 61 63 65 |in sever|al place|
|00005a10| 73 20 6d 61 79 20 6e 6f | 74 20 67 65 74 20 61 20 |s may no|t get a |
|00005a20| 6e 65 77 20 76 61 72 69 | 61 62 6c 65 20 61 6c 6c |new vari|able all|
|00005a30| 6f 63 61 74 65 64 20 74 | 6f 20 69 74 20 62 65 63 |ocated t|o it bec|
|00005a40| 61 75 73 65 20 74 68 65 | 20 76 61 72 69 61 62 6c |ause the| variabl|
|00005a50| 65 20 69 73 20 62 65 69 | 6e 67 20 6b 65 70 74 20 |e is bei|ng kept |
|00005a60| 69 6e 20 61 20 72 65 67 | 69 73 74 65 72 2e 20 41 |in a reg|ister. A|
|00005a70| 64 64 69 6e 67 20 61 20 | 63 6f 6e 73 74 61 6e 74 |dding a |constant|
|00005a80| 20 74 6f 20 61 20 72 65 | 67 69 73 74 65 72 20 69 | to a re|gister i|
|00005a90| 73 20 66 61 73 74 65 72 | 20 69 6e 20 74 65 72 6d |s faster| in term|
|00005aa0| 73 20 6f 66 20 65 78 65 | 63 75 74 69 6f 6e 20 73 |s of exe|cution s|
|00005ab0| 70 65 65 64 20 74 68 61 | 6e 20 63 72 65 61 74 69 |peed tha|n creati|
|00005ac0| 6e 67 20 61 20 73 70 65 | 63 69 61 6c 20 76 61 72 |ng a spe|cial var|
|00005ad0| 69 61 62 6c 65 20 61 6e | 64 20 72 65 66 65 72 65 |iable an|d refere|
|00005ae0| 6e 63 69 6e 67 20 69 74 | 2c 20 65 76 65 6e 20 74 |ncing it|, even t|
|00005af0| 68 6f 75 67 68 20 74 68 | 65 20 61 63 74 75 61 6c |hough th|e actual|
|00005b00| 20 6e 75 6d 62 65 72 20 | 6f 66 20 6d 61 63 68 69 | number |of machi|
|00005b10| 6e 65 20 69 6e 73 74 72 | 75 63 74 69 6f 6e 73 20 |ne instr|uctions |
|00005b20| 69 73 20 67 72 65 61 74 | 65 72 2e 20 28 49 6e 20 |is great|er. (In |
|00005b30| 74 68 69 73 20 63 61 73 | 65 2c 20 6f 6e 65 20 65 |this cas|e, one e|
|00005b40| 78 74 72 61 20 69 6e 73 | 74 72 75 63 74 69 6f 6e |xtra ins|truction|
|00005b50| 2e 29 20 41 20 70 72 6f | 67 72 61 6d 6d 65 72 20 |.) A pro|grammer |
|00005b60| 63 61 6e d5 74 20 6b 6e | 6f 77 20 77 68 61 74 20 |can.t kn|ow what |
|00005b70| 76 61 72 69 61 62 6c 65 | 73 20 77 69 6c 6c 20 62 |variable|s will b|
|00005b80| 69 6f 6e 20 65 78 69 73 | 74 73 2e 20 44 6f 6e d5 |ion exis|ts. Don.|
|00005b90| 74 20 67 65 74 20 63 61 | 75 67 68 74 20 69 6e 20 |t get ca|ught in |
|00005ba0| 74 68 65 20 4e 6f 74 20 | 49 6e 76 65 6e 74 65 64 |the Not |Invented|
|00005bb0| 20 48 65 72 65 20 73 79 | 6e 64 72 6f 6d 65 2e 0d | Here sy|ndrome..|
|00005bc0| 2b 09 53 65 65 20 69 66 | 20 73 6f 6d 65 62 6f 64 |+.See if| somebod|
|00005bd0| 79 20 68 61 73 20 61 6c | 72 65 61 64 79 20 77 72 |y has al|ready wr|
|00005be0| 69 74 74 65 6e 20 61 6e | 20 6f 70 74 69 6d 69 7a |itten an| optimiz|
|00005bf0| 65 64 20 76 65 72 73 69 | 6f 6e 20 6f 66 20 61 20 |ed versi|on of a |
|00005c00| 66 75 6e 63 74 69 6f 6e | 20 79 6f 75 20 6e 65 65 |function| you nee|
|00005c10| 64 2e 20 54 61 6b 65 20 | 73 61 6d 70 6c 65 20 74 |d. Take |sample t|
|00005c20| 69 6d 69 6e 67 73 20 61 | 6e 64 20 67 6f 20 77 69 |imings a|nd go wi|
|00005c30| 74 68 20 74 68 65 20 66 | 61 73 74 65 72 20 76 65 |th the f|aster ve|
|00005c40| 72 73 69 6f 6e 2e 0d 0d | 4d 65 6d 6f 72 79 20 4d |rsion...|Memory M|
|00005c50| 61 6e 61 67 65 6d 65 6e | 74 20 4f 70 74 69 6d 69 |anagemen|t Optimi|
|00005c60| 7a 61 74 69 6f 6e 73 0d | 54 68 65 20 4d 65 6d 6f |zations.|The Memo|
|00005c70| 72 79 20 4d 61 6e 61 67 | 65 72 20 69 73 20 20 20 |ry Manag|er is |
|00005c80| 6d 6f 72 79 20 6d 6f 76 | 65 73 2e 29 0d 45 61 63 |mory mov|es.).Eac|
|00005c90| 68 20 75 73 65 20 6f 66 | 20 61 6e 20 69 6e 73 74 |h use of| an inst|
|00005ca0| 61 6e 63 65 20 76 61 72 | 69 61 62 6c 65 20 69 6e |ance var|iable in|
|00005cb0| 76 6f 6c 76 65 73 20 64 | 65 2d 72 65 66 65 72 65 |volves d|e-refere|
|00005cc0| 6e 63 69 6e 67 20 74 68 | 65 20 6f 62 6a 65 63 74 |ncing th|e object|
|00005cd0| 20 68 61 6e 64 6c 65 20 | 28 69 6d 70 6c 69 63 69 | handle |(implici|
|00005ce0| 74 6c 79 20 64 6f 6e 65 | 20 62 79 20 74 68 65 20 |tly done| by the |
|00005cf0| 63 6f 6d 70 69 6c 65 72 | 29 20 77 68 69 63 68 20 |compiler|) which |
|00005d00| 74 61 6b 65 73 20 61 74 | 20 6c 65 61 73 74 20 74 |takes at| least t|
|00005d10| 77 6f 20 6d 61 63 68 69 | 6e 65 20 69 6e 73 74 72 |wo machi|ne instr|
|00005d20| 75 63 74 69 6f 6e 73 2e | 20 49 66 20 79 6f 75 20 |uctions.| If you |
|00005d30| 6e 65 65 64 20 74 6f 20 | 75 73 65 20 61 6e 20 69 |need to |use an i|
|00005d40| 6e 73 74 61 6e 63 65 20 | 76 61 72 69 61 62 6c 65 |nstance |variable|
|00005d50| 20 6d 6f 72 65 20 74 68 | 61 6e 20 74 77 69 63 65 | more th|an twice|
|00005d60| 20 69 6e 20 61 20 72 6f | 75 74 69 6e 65 2c 20 63 | in a ro|utine, c|
|00005d70| 72 65 61 74 65 20 61 20 | 6c 6f 63 61 6c 20 76 76 |reate a |local vv|
|00005d80| 6e 74 20 28 6f 72 20 63 | 61 73 65 20 73 74 61 74 |nt (or c|ase stat|
|00005d90| 65 6d 65 6e 74 20 69 6e | 20 50 61 73 63 61 6c 29 |ement in| Pascal)|
|00005da0| 20 61 6c 6c 6f 77 73 20 | 66 6f 72 20 61 20 6d 75 | allows |for a mu|
|00005db0| 6c 74 69 70 6c 65 20 63 | 68 6f 69 63 65 20 62 72 |ltiple c|hoice br|
|00005dc0| 61 6e 63 68 2e 20 49 74 | 20 69 73 20 66 75 6e 63 |anch. It| is func|
|00005dd0| 74 69 6f 6e 61 6c 6c 79 | 20 65 71 75 69 76 61 6c |tionally| equival|
|00005de0| 65 6e 74 20 74 6f 20 6d | 75 6c 74 69 70 6c 65 20 |ent to m|ultiple |
|00005df0| 73 75 63 63 65 73 73 69 | 76 65 20 69 66 2f 74 68 |successi|ve if/th|
|00005e00| 65 6e 2f 65 6c 73 65 20 | 73 74 61 74 65 6d 65 6e |en/else |statemen|
|00005e10| 74 73 2e 20 43 6f 6d 70 | 69 6c 65 72 73 20 63 61 |ts. Comp|ilers ca|
|00005e20| 6e 20 6d 61 6b 65 20 73 | 77 69 74 63 68 20 73 74 |n make s|witch st|
|00005e30| 61 74 65 6d 65 6e 74 73 | 20 66 61 73 74 65 72 20 |atements| faster |
|00005e40| 74 68 61 6e 20 69 66 20 | 73 74 61 74 65 6d 65 6e |than if |statemen|
|00005e50| 74 73 20 62 65 63 61 75 | 73 65 20 74 68 65 20 73 |ts becau|se the s|
|00005e60| 77 69 74 63 68 20 69 73 | 20 6f 6e 6c 79 20 63 6f |witch is| only co|
|00005e70| 6d 70 75 74 65 64 20 6f | 6e 63 65 2c 20 69 6e 73 |mputed o|nce, ins|
|00005e80| 20 69 6e 20 74 68 65 20 | 61 72 72 61 79 20 69 73 | in the |array is|
|00005e90| 20 61 63 74 75 61 6c 6c | 79 20 73 74 6f 72 65 64 | actuall|y stored|
|00005ea0| 20 69 6e 73 69 64 65 20 | 74 68 65 20 68 61 6e 64 | inside |the hand|
|00005eb0| 6c 65 20 77 68 69 63 68 | 20 63 6f 6e 74 61 69 6e |le which| contain|
|00005ec0| 73 20 74 68 65 20 69 6e | 73 74 61 6e 63 65 20 76 |s the in|stance v|
|00005ed0| 61 72 69 61 62 6c 65 73 | 2e 20 53 69 6e 63 65 20 |ariables|. Since |
|00005ee0| 74 68 65 20 68 61 6e 64 | 6c 65 20 6d 61 79 20 6d |the hand|le may m|
|00005ef0| 6f 76 65 2c 20 74 68 65 | 20 61 72 72 61 79 20 69 |ove, the| array i|
|00005f00| 74 73 65 6c 66 20 77 69 | 6c 6c 20 6d 6f 76 65 2c |tself wi|ll move,|
|00005f10| 20 6c 65 61 76 69 6e 67 | 20 6e 6f 20 70 72 61 63 | leaving| no prac|
|00005f20| 74 69 63 61 6c 20 77 61 | 79 20 74 6f 20 61 63 63 |tical wa|y to acc|
|00005f30| 65 73 73 20 74 68 65 20 | 64 61 74 61 20 66 72 6f |ess the |data fro|
|00005f40| 6d 20 61 20 6c 6f 63 61 | 6c 20 70 6f 69 6e 74 65 |m a loca|l pointe|
|00005f50| 72 2e 0d 2b 09 43 6f 70 | 79 20 61 6e 79 20 69 6e |r..+.Cop|y any in|
|00005f60| 73 74 61 6e 63 65 20 76 | 61 72 69 61 62 6c 65 20 |stance v|ariable |
|00005f70| 75 73 65 64 20 6d 6f 72 | 65 20 74 68 61 6e 20 74 |used mor|e than t|
|00005f80| 68 20 65 78 70 72 65 73 | 73 69 6f 6e 20 28 6b 65 |h expres|sion (ke|
|00005f90| 70 74 20 69 6e 20 61 20 | 6d 61 63 68 69 6e 65 20 |pt in a |machine |
|00005fa0| 72 65 67 69 73 74 65 72 | 29 2e 20 41 20 42 72 61 |register|). A Bra|
|00005fb0| 6e 63 68 20 6f 6e 20 45 | 71 75 61 6c 20 28 42 45 |nch on E|qual (BE|
|00005fc0| 51 29 20 69 6e 73 74 72 | 75 63 74 69 6f 6e 20 69 |Q) instr|uction i|
|00005fd0| 73 20 74 68 65 6e 20 65 | 78 65 63 75 74 65 64 2c |s then e|xecuted,|
|00005fe0| 20 73 6f 20 69 66 20 74 | 68 65 20 76 61 6c 75 65 | so if t|he value|
|00005ff0| 20 69 73 20 7a 65 72 6f | 2c 20 74 68 61 74 20 63 | is zero|, that c|
|00006000| 61 73 65 20 69 6e 20 74 | 68 65 20 73 77 69 74 63 |ase in t|he switc|
|00006010| 68 20 69 73 20 65 78 65 | 63 75 74 65 64 2e 20 49 |h is exe|cuted. I|
|00006020| 66 20 69 74 20 69 73 20 | 6e 6f 74 2c 20 74 68 65 |f it is |not, the|
|00006030| 6e 20 61 20 63 6f 6d 70 | 69 6c 65 72 20 67 65 6e |n a comp|iler gen|
|00006040| 65 72 61 74 65 64 20 63 | 6f 6e 73 74 61 6e 74 20 |erated c|onstant |
|00006050| 69 73 20 73 75 62 74 72 | 61 63 74 20 66 72 6f 6d |is subtr|act from|
|00006060| 20 74 68 65 20 63 75 72 | 72 65 6e 74 20 76 61 6c | the cur|rent val|
|00006070| 75 65 20 6f 66 20 74 68 | 65 20 73 77 69 74 63 68 |ue of th|e switch|
|00006080| 20 65 78 70 72 65 73 73 | 69 6f 6e 20 61 6e 64 20 | express|ion and |
|00006090| 74 68 65 20 70 72 6f 63 | 65 73 73 20 69 73 20 72 |the proc|ess is r|
|000060a0| 65 70 65 61 74 65 64 2e | 0d 4f 70 74 69 6d 69 7a |epeated.|.Optimiz|
|000060b0| 69 6e 67 20 61 20 73 77 | 69 74 63 68 20 73 74 61 |ing a sw|itch sta|
|000060c0| 74 65 6d 65 6e 74 20 69 | 73 20 73 69 6d 70 6c 65 |tement i|s simple|
|000060d0| 2e 20 50 75 74 20 74 68 | 65 20 6d 6f 73 74 20 63 |. Put th|e most c|
|000060e0| 6f 6d 6d 6f 6e 20 63 61 | 73 65 20 66 6f 72 20 74 |ommon ca|se for t|
|000060f0| 68 65 20 73 77 69 74 63 | 68 20 74 6f 20 75 73 65 |he switc|h to use|
|00006100| 20 61 74 20 74 68 65 20 | 74 6f 70 20 6f 66 20 74 | at the |top of t|
|00006110| 68 65 20 73 6f 75 72 63 | 65 20 63 6f 64 65 20 66 |he sourc|e code f|
|00006120| 6f 72 20 74 68 65 20 73 | 77 69 74 63 68 2e 20 46 |or the s|witch. F|
|00006130| 6f 72 20 69 6e 73 74 61 | 6e 63 65 2c 20 74 6f 20 |or insta|nce, to |
|00006140| 6d 61 6b 65 20 74 68 65 | 20 6d 61 69 6e 20 65 76 |make the| main ev|
|00006150| 65 6e 74 20 6c 6f 6f 70 | 20 6f 66 20 61 20 70 72 |ent loop| of a pr|
|00006160| 6f 67 72 61 6d 20 73 6c | 69 67 68 74 6c 79 20 66 |ogram sl|ightly f|
|00006170| 61 73 74 65 72 20 28 61 | 6c 77 61 79 73 20 69 6d |aster (a|lways im|
|00006180| 70 6f 72 74 61 6e 74 20 | 73 69 6e 63 65 20 6d 75 |portant |since mu|
|00006190| 6c 74 69 2d 74 61 73 6b | 69 6e 67 20 6f 6e 6c 79 |lti-task|ing only|
|000061a0| 20 68 61 70 70 65 6e 73 | 20 64 75 72 69 6e 67 20 | happens| during |
|000061b0| 61 20 57 61 69 74 4e 65 | 78 74 45 76 65 6e 74 20 |a WaitNe|xtEvent |
|000061c0| 63 61 6c 6c 20 6f 6e 20 | 74 68 65 20 4d 61 63 69 |call on |the Maci|
|000061d0| 6e 74 6f 73 68 29 2c 20 | 70 75 74 20 74 68 65 20 |ntosh), |put the |
|000061e0| 63 68 65 63 6b 20 66 6f | 72 20 61 20 6e 75 6c 6c |check fo|r a null|
|000061f0| 20 65 76 65 6e 74 20 61 | 73 20 74 68 65 20 76 65 | event a|s the ve|
|00006200| 72 79 20 66 69 72 73 74 | 20 63 61 73 65 20 74 6f |ry first| case to|
|00006210| 20 63 68 65 63 6b 20 69 | 6e 20 61 6e 20 65 76 65 | check i|n an eve|
|00006220| 6e 74 20 73 77 69 74 63 | 68 2e 20 4e 75 6c 6c 20 |nt switc|h. Null |
|00006230| 65 76 65 6e 74 73 20 61 | 72 65 20 74 68 65 20 6d |events a|re the m|
|00006240| 6f 73 74 20 63 6f 6d 6d | 6f 6e 20 65 76 65 6e 74 |ost comm|on event|
|00006250| 20 6f 6e 20 74 68 65 20 | 4d 61 63 69 6e 74 6f 73 | on the |Macintos|
|00006260| 68 2e 20 49 66 20 79 6f | 75 20 63 68 65 63 6b 20 |h. If yo|u check |
|00006270| 66 6f 72 20 38 20 65 76 | 65 6e 74 73 20 62 65 73 |for 8 ev|ents bes|
|00006280| 69 64 65 73 20 74 68 65 | 20 6e 75 6c 6c 20 65 76 |ides the| null ev|
|00006290| 65 6e 74 2c 20 62 65 66 | 6f 72 65 20 79 6f 75 20 |ent, bef|ore you |
|000062a0| 63 68 65 63 6b 20 66 6f | 72 20 74 68 65 20 6e 75 |check fo|r the nu|
|000062b0| 6c 6c 20 65 76 65 6e 74 | 2c 20 79 6f 75 20 61 72 |ll event|, you ar|
|000062c0| 65 20 65 78 65 63 75 74 | 69 6e 67 20 65 69 67 68 |e execut|ing eigh|
|000062d0| 74 20 73 75 62 74 72 61 | 63 74 69 6f 6e 73 20 61 |t subtra|ctions a|
|000062e0| 6e 64 20 65 69 67 68 74 | 20 66 61 69 6c 65 64 20 |nd eight| failed |
|000062f0| 42 45 51 20 69 6e 73 74 | 72 75 63 74 69 6f 6e 73 |BEQ inst|ructions|
|00006300| 20 65 61 63 68 20 74 69 | 6d 65 20 74 68 72 6f 75 | each ti|me throu|
|00006310| 67 68 20 79 6f 75 72 20 | 65 76 65 6e 74 20 6c 6f |gh your |event lo|
|00006320| 6f 70 2e 20 28 54 68 65 | 20 74 69 6d 65 20 66 6f |op. (The| time fo|
|00006330| 72 20 74 68 65 20 73 75 | 62 74 72 61 63 74 69 6f |r the su|btractio|
|00006340| 6e 20 69 73 20 34 20 6d | 61 63 68 69 6e 65 20 63 |n is 4 m|achine c|
|00006350| 79 63 6c 65 73 2c 20 69 | 66 20 61 6c 6c 20 74 68 |ycles, i|f all th|
|00006360| 65 20 63 61 73 65 73 20 | 66 69 74 20 69 6e 74 6f |e cases |fit into|
|00006370| 20 61 20 74 77 6f 20 62 | 79 74 65 20 76 61 6c 75 | a two b|yte valu|
|00006380| 77 69 63 65 20 74 6f 20 | 61 20 6c 6f 63 61 6c 20 |wice to |a local |
|00006390| 76 61 72 69 61 62 6c 65 | 20 66 6f 72 20 66 61 73 |variable| for fas|
|000063a0| 74 65 72 20 61 63 63 65 | 73 73 2e 0d 76 09 42 65 |ter acce|ss..v.Be|
|000063b0| 20 63 61 72 65 66 75 6c | 20 74 6f 20 6d 61 69 6e | careful| to main|
|000063c0| 74 61 69 6e 20 74 68 65 | 20 63 75 72 72 65 6e 74 |tain the| current|
|000063d0| 20 76 61 6c 75 65 20 69 | 66 20 61 20 63 61 6c 6c | value i|f a call|
|000063e0| 65 64 20 6d 65 74 68 6f | 64 20 6d 61 79 20 63 68 |ed metho|d may ch|
|000063f0| 61 6e 67 65 20 6f 72 20 | 61 63 63 65 73 73 20 74 |ange or |access t|
+--------+-------------------------+-------------------------+--------+--------+
Only 25.0 KB of data is shown above.